Skip to content

Follow-up to #1775: title_template regression tests do not fail on the defect they claim to guard - #1784

Merged
malibio merged 3 commits into
mainfrom
worktree-issue-1775-followup-test-ratchet
Jul 28, 2026
Merged

malibio merged 3 commits into
mainfrom
worktree-issue-1775-followup-test-ratchet

Conversation

@malibio

@malibio malibio commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Closes #1783

malibio added a commit that referenced this pull request Jul 28, 2026
Review of #1784 found the sweep incomplete: three MarkdownError sites in
markdown/mod.rs still produced "invalid params: Invalid parameters: ...", and
one of them is in handle_create_nodes_from_markdown — the very function this
branch already touches from the tools.rs side. That is the same "one function
away" argument this branch accepted for schema/mod.rs, so leaving them was
inconsistent and the commit message read as if the sweep were complete.

Deliberately NOT changed, having checked each:
- node_batch.rs:64/114 return a plain String with no Display prefix, so their
  "Invalid parameters:" text is load-bearing rather than redundant.
- ops/mod.rs:40 is a thiserror attribute on a different error type.
- markdown/mod.rs:1194 says "Invalid collection path", a distinct message that
  happens to start with the same word — not a doubled preamble.

No MarkdownError construction now doubles the preamble.

core 1013 passed, agent 309 passed, clippy clean.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01C2fwCrhS3Bfq4uDGM61iCr
@malibio

malibio commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

Code review: APPROVE (with one finding, now addressed)

Reviewed by /pragmatic-code-review. The reviewer was explicitly asked not to trust the authors claim that the ratchet works, since the author had already been wrong once about these exact assertions.

Independently verified

The reviewer reconstructed the diverging pre-check from its original commit, re-inserted it at the original call site, and ran the suite:

test ..._empty_placeholder_rejected ... FAILED
  ... a different message here means a second validator spoke first:
  invalid params: title_template "{} {status}" references {status}, which is not
  defined in "fields". Either add {"name":"status","type":"text"} ...
test ..._unclosed_placeholder_rejected ... ok

The ratchet fires, for exactly the claimed reason. The file was then restored; worktree confirmed clean.

Three things it tried to break and could not

  • Asserted literals match validate_template_tokens byte-for-byte, including the '{' quoting. A typo would have made the "tightened" assertion weaker than the loose one it replaced — this was the highest-risk item and it is clean.
  • fields: [] is not arbitrary. It deserializes to Some(vec![]) and takes the explicit-fields branch, whereas an absent key is None and falls to the description branch. Different paths; the chosen fixture is the one that mirrors what the pre-check actually read.
  • The "un-pinnable" claim on the unclosed case is a correct structural observation, not a cop-out. Both validators return the same error variant, so message text is the only signal; anything stronger would need production-visible test machinery.

🟡 Finding — addressed in d3ca89b

The sweep was incomplete: three MarkdownError sites in markdown/mod.rs still produced invalid params: Invalid parameters: ..., one of them in handle_create_nodes_from_markdown — the very function this branch already touches from the tools.rs side. That is the same "one function away" argument this branch accepted for schema/mod.rs, so leaving them was inconsistent.

Fixed. Deliberately left, having checked each:

  • node_batch.rs:64/114 — plain String with no Display prefix, so the text is load-bearing.
  • ops/mod.rs:40 — thiserror attribute on a different error type.
  • markdown/mod.rs:1194 — "Invalid collection path", a distinct message, not a doubled preamble.

No MarkdownError construction now doubles the preamble.

Re-review decision

NO RE-REVIEW NEEDED. d3ca89be is a mechanical string-prefix change with no behavioural or logic change, which is squarely the "trivial, low-risk" case. The reviewed commit d43b7a24 is unchanged.

core 1013 passed · agent 309 passed · frontend 4104 passed · clippy clean · full push gate passed.

malibio and others added 3 commits July 28, 2026 21:21
…loses #1783)

A post-hoc review of #1775 — commissioned because the fixes applied after that
PR's review were never re-reviewed before merge — found that the two tests I
claimed would catch a reintroduced pre-check pass with or without it. The claim
in that commit message was false.

The cause is my own fixture: the divergence table specified fields:[] for the
empty-placeholder case, because an empty fields array is what makes the
pre-check emit its confidently-wrong prescription. I wrote the test with
fields:[{name:"status"}], which resolves the placeholder, empties the
pre-check's `missing` list, silences it, and lets the authority run anyway. I
documented the right fixture and then used the wrong one.

- empty-placeholder test: fields corrected to [], assertion tightened to the
  authority's exact phrasing so a second validator speaking first is detected.
  Verified by reintroducing the diverging pre-check and confirming this test
  fails with "a different message here means a second validator spoke first",
  then removing it. It is a real ratchet now, demonstrated rather than assumed.
- unclosed-placeholder test: this input is structurally un-pinnable by an
  outcome assertion — pre-check and authority AGREE on the outcome and differ
  only in who speaks. Dropped the guarantee it cannot provide; it now asserts
  the authority's exact wording, which catches a reintroduction that rewords
  the error, and the comment says exactly that.

Also the two remaining review items:

- agent_loop.rs tail-inference comment claimed "Reached only via the
  duplicate-call guard's break"; #1775's parse-failure guard made that a second
  entry point, so the comment was a trap for the next reader debugging it.
- The Display/Debug sweep I skipped from #1775 as scope creep. The review
  judged that call wrong — the same change fixed this defect one function away
  and added a comment explaining why the doubled preamble harms the model,
  while leaving four sites producing "invalid params: Invalid parameters: ..."
  in the same file, one on the adjacent line. Fixed those four, plus the
  MarkdownError still Debug-formatted in create_nodes_from_markdown.

The lesson worth keeping: verify a regression test by reintroducing the defect.
A test that passes either way is worse than no test, because the claim beside it
invites trust in a ratchet that is not there.

core 1013 passed, agent 309 passed, clippy clean.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01C2fwCrhS3Bfq4uDGM61iCr
Review of #1784 found the sweep incomplete: three MarkdownError sites in
markdown/mod.rs still produced "invalid params: Invalid parameters: ...", and
one of them is in handle_create_nodes_from_markdown — the very function this
branch already touches from the tools.rs side. That is the same "one function
away" argument this branch accepted for schema/mod.rs, so leaving them was
inconsistent and the commit message read as if the sweep were complete.

Deliberately NOT changed, having checked each:
- node_batch.rs:64/114 return a plain String with no Display prefix, so their
  "Invalid parameters:" text is load-bearing rather than redundant.
- ops/mod.rs:40 is a thiserror attribute on a different error type.
- markdown/mod.rs:1194 says "Invalid collection path", a distinct message that
  happens to start with the same word — not a doubled preamble.

No MarkdownError construction now doubles the preamble.

core 1013 passed, agent 309 passed, clippy clean.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01C2fwCrhS3Bfq4uDGM61iCr
Rebasing onto main brought in the namespace-prefix fix, which makes
description-only create_schema succeed. This test was written while that path
was broken: it asserted only that the field-locating pass stayed out of the way,
guarded behind `if let Err`, deliberately not pinning success so it would not
couple to that bug's fix.

With the bug fixed the guard makes the test VACUOUS — the Err branch never runs,
so it passes without asserting anything. That is precisely the failure mode this
branch exists to correct, so leaving it would be self-defeating.

Now asserts the call succeeds and returns schemaId "venue". The stale comment
claiming the path is "separately broken on main" is gone.

core 1019 passed (up from 1013, #1777's tests included), agent 309 passed,
clippy clean.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01C2fwCrhS3Bfq4uDGM61iCr
@malibio
malibio force-pushed the worktree-issue-1775-followup-test-ratchet branch from d3ca89b to 8660094 Compare July 28, 2026 19:28
@malibio

malibio commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto main after #1777 landed (dc3a2888). Clean rebase, no conflicts — but it did change one test's meaning, so one commit added.

test_create_schema_without_fields_key_is_unaffected was written while description-only create_schema was broken by the custom: prefix bug. It deliberately asserted only that the field-locating pass stayed out of the way, guarded behind if let Err, so it would not couple to that bug's fix.

#1777 fixes that path — which makes the guard vacuous: the Err branch never runs, so the test passes without asserting anything. That is exactly the failure mode this PR exists to correct, so leaving it would be self-defeating. It now asserts the call succeeds and returns schemaId: "venue", and the stale "separately broken on main" comment is gone.

Reviewed commit d43b7a24 (now 751d149c) is unchanged by the rebase apart from its new base.

core 1019 passed (up from 1013 — #1777's tests now included) · agent 309 · clippy clean · full push gate passed.

@malibio
malibio merged commit 7dcae76 into main Jul 28, 2026
2 checks passed
@malibio
malibio deleted the worktree-issue-1775-followup-test-ratchet branch July 28, 2026 19:29
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.

Follow-up to #1775: title_template regression tests do not fail on the defect they claim to guard

1 participant