Skip to content

Address retro-review: assert scenario 6's golden test, fix pre-existing lint - #1928

Merged
malibio merged 2 commits into
mainfrom
issue-1917-address-review-fixes
Aug 2, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-1917-address-review-fixes

Conversation

@malibio

@malibio malibio commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR is a corrective follow-up after 8 commits landed directly on main this session without a PR or /pragmatic-code-review — a real process violation. A retro review was run against the full unreviewed range (db708a90..83bdabed) and this PR addresses its two 🔴 Critical findings.

What this addresses

  1. stage1_reformulation_for_scenario_6_update had no assertion. It only printed Stage-1's route_query output for a human to eyeball, so it would stay green through a regression back to the pre-fix behavior ("equipment items on the books" — dropping the update intent and discriminating value) that commit 83bdabed was supposed to fix. Added real assertions: the query must preserve the discriminating value (2400) and an update/state-change marker. Clarify/None outcomes now fail loudly instead of silently printing. Verified live against the real model — passes with today's actual output ("set laser cutter to returned with replacement cost 2400"). Re-ran all 4 golden tests in the file sequentially (single-threaded, ruling out GPU contention) — all pass.

  2. Pre-existing vec_init_then_push clippy lint in golden_scenario6_handauthored.rs, surfaced by running quality:fix here for the first time on this range (an earlier unreviewed commit never ran it before pushing). Converted to vec![...].

Retro-review finding NOT actioned here (corrected, not a defect)

The retro review also flagged a scenario-8b regression as "silently dropped from the narrative." That's not accurate — it's tracked as #1926 (filed same session, full root-cause trace: a grammar-decoder JSON corruption artifact on create_schema retry, unrelated to history rendering). The review agent didn't have visibility into the issue-comment trail, only the git diff. No code change needed for that finding.

Not addressed (scope decision, documented)

  • 🟡 Pruning/asserting the 4 unasserted "discriminating experiment" probes in golden_scenario6_handauthored.rs — that's #1925-cluster fixture cleanup, not a defect introduced by the 8 commits under review. Scope creep for this corrective PR; worth a separate pass.
  • 🟡 Debug logging in terse_write_fact's .ok()? fallback — cosmetic, no functional issue.
  • 🟢 All three nitpicks — none affect correctness (the create_schema fallback-subject one is confirmed unreachable per the tool schema).

Testing

  • cargo test -p nodespace-agent --lib — 425 passed, 0 failed
  • cargo test -p nodespace-agent --test live_stage1_golden_prompts -- --ignored --nocapture --test-threads=1 — all 4 golden tests pass live against the real model
  • Full pre-push gate (bun run test:all + cargo build --bin nodespaced + cargo test -p nodespace-app) — green

Process note

This PR itself follows the correct flow (branch → PR → review) specifically because it exists to remediate a session where that flow was skipped. Retro review findings are also being posted to #1917 as an issue comment for the audit trail, since the original 8 commits have no PR thread to attach them to.

malibio and others added 2 commits August 2, 2026 21:33
…st print

Retro /pragmatic-code-review of the 8 commits merged directly to main
without a PR (db708a9..83bdabe) flagged that
stage1_reformulation_for_scenario_6_update only printed Stage-1's
route_query output for a human to eyeball — it had no assertion, so it
would stay green through a regression back to the pre-fix behavior
("equipment items on the books", dropping the update intent and the
discriminating value) that commit 83bdabe exists to prevent.

Adds assertions that the query preserves the discriminating value
("2400") and an update/state-change marker (return/update/set),
matching the fix's actual claim. Also turns the Clarify/None arms from
silent no-ops into explicit failures, since either outcome means the
fix regressed (Stage-1 should describe this as a capability, not ask
to clarify or produce nothing).

Verified live against the real model (not just compiled): passes with
today's actual output, "set laser cutter to returned with replacement
cost 2400". Re-ran all 4 golden tests in this file sequentially
(single-threaded, to rule out Metal/GPU contention as a confound) —
all 4 pass, no regressions from the added assertions.

Co-Authored-By: Claude <[email protected]>
- golden_scenario6_handauthored.rs: vec_init_then_push clippy lint
  (Vec::new() + repeated push -> vec![...]), a pre-existing issue from
  an earlier unreviewed commit surfaced by running quality:fix here.
- live_stage1_golden_prompts.rs: cargo fmt formatting on lines this
  commit and an earlier session both touched without ever running
  quality:fix before pushing.

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

This is a narrow, well-scoped corrective PR that does exactly what it says: replaces a print-only golden test with a real assertion, and cleans up a pre-existing clippy/fmt violation. Verification included independently re-deriving the diff, reading the full surrounding file content (not just hunks), checking the route_query tool schema and build_retrieval_query helper the test exercises, and running cargo fmt --check and cargo clippy --tests -D warnings directly against the PR branch. Both new assertions are well-targeted at the specific regression they're guarding against, the Vec::new()+push → vec![] transform is a faithful mechanical rewrite with no reordering/omission, and the remaining hunks are pure rustfmt reflows. This is a clear net positive. One item is worth a non-blocking follow-up: latent format-brittleness in the "2400" substring check.

Requirements Check

  • ✅ Assert stage1_reformulation_for_scenario_6_update's actual output instead of only printing it — done, with two targeted assertions plus panic! on the two previously-silent non-Query arms.
  • ✅ Fix the pre-existing vec_init_then_push clippy lint in golden_scenario6_handauthored.rs — done, confirmed as a pure Vec::new() + 6×.push() → vec![...] transform, same 6 elements, same order (User/Assistant/System/User/Assistant/System).
  • ✅ Scope discipline — PR touches only the two files/gaps named in its own description; the retro-review's other findings are explicitly and reasonably deferred, not silently dropped.

Code Review Findings

Critical Issues

None.

Suggested Improvements

🟡 packages/agent/tests/live_stage1_golden_prompts.rs:238 (lower.contains("2400"))

This is a plain substring check against a lower-cased string, so it only survives if the model emits the bare digit sequence 2400. Checking the tool schema the model is actually prompted with (stage1_tool_definitions() in packages/agent/src/local_agent/routing.rs), its query parameter description contains the literal few-shot example "update the equipment record worth 2400 to returned" — i.e. the model is directly primed toward the exact bare-digit format this assertion checks for. That materially de-risks the "what if it says $2,400 or 2,400" concern for this model/prompt pairing, but the coupling is implicit — nothing ties the assertion to that specific example string. If a future prompt-wording change to route_query's description swaps the example to a currency-formatted or comma-separated number, this test could start failing for a reason unrelated to the regression it exists to catch.

Recommendation: A one-line comment noting the assertion's implicit dependency on that example phrasing would help a future editor of routing.rs know to check this test. Not a blocker — today's coupling is real and intentional, just undocumented.

🟢 packages/agent/tests/live_stage1_golden_prompts.rs:242 (the return/update/set OR-check)

Appropriately loose given the tool description explicitly offers update/create/delete/list as the vocabulary the model is nudged toward, and the golden prompt's own wording ("set it to returned") makes at least one of these three appearing in a faithful reformulation highly likely. The theoretical false-positive risk (a broken output that happens to contain "set" or "update" for an unrelated reason while still failing to capture the real intent) is real in the abstract but low in practice, since the same output must also pass the independent "2400" check — the two assertions compose as an AND, meaningfully narrowing the space of accidentally-passing garbage. No change needed.

Nitpicks

Nit: packages/agent/tests/live_stage1_golden_prompts.rs:264 (None => panic!(...)) — the panic message ("Stage 1 called no tool or emitted unparseable arguments") is good; it distinguishes the two collapsed cases in the message even though parse_route_decision collapses them into one None. No action needed.

Verification Notes (targeted questions)

  1. Assertion correctness / format brittleness — addressed above. Net: reasonable today because of tool-schema priming, slightly implicit coupling worth documenting.

  2. Clarify/None → panic! — Correct and not a flakiness risk. route_clarify's own tool description in routing.rs restricts it to "Use ONLY when the request is too ambiguous to describe as a capability." The golden prompt "The 2400 one came back — set it to returned," combined with the two prior turns establishing the laser cutter / 2400 record, leaves no plausible ambiguity a well-behaved model should flag: one referent ("the 2400 one"), one clear state change ("set it to returned"), no missing information a clarifying question could productively resolve. A Clarify response here would itself be the bug, not a legitimate alternate behavior — gating on it with panic! is correct. The PR's own testing evidence (4/4 live runs, sequential/single-threaded to rule out GPU-contention nondeterminism) supports this isn't a coin-flip outcome. None similarly represents a real failure mode (unparseable/no tool call) rather than a legitimate response.

  3. vec_init_then_push transform — Confirmed via direct read of both pre- and post-image of the full file (not just the diff hunk): six elements, same order (User → Assistant → System → User → Assistant → System), same content, no reordering/omission/duplication. Pure mechanical fix.

  4. Other formatting-only hunks — Confirmed via cargo fmt --check run directly against the PR branch (HEAD de4dd382). The Arc::new(...) line wrap, both println! wraps, the use import wrap, and the multi-line run_stage1(...)/run_stage1_with_history(...) call reflows in both files are pure rustfmt output with no logic changes. Also ran cargo clippy -p nodespace-agent --tests --no-deps -- -D warnings, which built clean with zero warnings, confirming the vec_init_then_push fix actually resolves the lint and introduces no new ones. Note: cargo fmt --check on the full package still flags unformatted code in packages/agent/tests/golden_scenario6_sequence.rs, but that file is not part of this PR's diff (confirmed against gh pr view --json files) and was introduced by a later, separate commit on main (35f0154d). Pre-existing drift outside this PR's scope, not a regression it introduced.

  5. Process/scope — The deferral of fixture cleanup (Compact conversation history in the acting-turn prompt toward the confirmed scenario-6 golden shape #1925-cluster), the cosmetic .ok()? logging nit, and the three nitpicks is reasonable scope discipline for a corrective PR. Per "Net Positive > Perfection," a corrective PR remediating a specific process violation should stay narrowly targeted at the two Critical findings it names rather than absorbing unrelated cleanup — bundling them in would violate the "atomic, single cohesive purpose" principle. Posting the retro-review's findings to issue Autonomous goal: drive local-agent matrix reliability to 10/12+ without turn-by-turn relay #1917 as a comment is sensible given the original 8 commits landed with no PR thread to attach review comments to.

Recommendation

APPROVE

The two Critical gaps from the retro-review are correctly and verifiably fixed: the golden test now actually gates on the fix's claim instead of relying on human eyeballing, and the clippy/fmt issues are clean mechanical fixes with no behavioral change. The format-brittleness note on the "2400" substring check is worth a follow-up comment for future maintainability but does not block merge — it reflects real, verified coupling to the current tool-schema example text, not a speculative risk.

@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.

Reviewed via /pragmatic-code-review — full findings posted as a PR comment above. Recommendation: APPROVE (GitHub blocks self-approval on this PR's authoring account, so recording verdict via comment review instead). Both Critical retro-review gaps are correctly and verifiably fixed: real assertions on the golden test replacing print-only output, and a clean mechanical clippy fix with no behavior change. One non-blocking follow-up noted: format-brittleness of the "2400" substring check (implicit coupling to the tool-schema example phrasing).

@malibio
malibio merged commit 67b1052 into main Aug 2, 2026
2 checks passed
@malibio
malibio deleted the issue-1917-address-review-fixes branch August 2, 2026 20:20
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.

1 participant