Repository navigation
create_schema description route folds the type keyword into the inferred field name - #1794
Conversation
#1789) The description route consumed a trailing type keyword for type inference and also kept it in the stored name, so `{"description": "capacity number"}` stored a field called `capacity_number` while the explicit-fields route stored `capacity` for the same intent. Stored names are user-visible keys — they resolve title-template tokens, CEL selectors, query filters and frontend lookups — so the two call shapes have to agree. A trailing bare type keyword (number, date, text, string, boolean, list, array) is now dropped from the inferred name. "capacity number" and "invoice number" are structurally identical, so intent cannot be read from the phrase: names where the keyword is intrinsic are recorded in a keep-list of preceding nouns (invoice/phone/account/... + number, birth/due + date) and left untouched. `due` is on the keep-list deliberately. `due_date` is a core task property, so stripping "due date" to `due` would both disagree with the "due_date" spelling and slip past the reserved-core-property warning a collision should raise. Type inference is unchanged: it still runs against the full description before the name is shortened, so "capacity number" yields `capacity` of type number. Every strip emits a warning naming the stored key, through the existing InferredField.warnings channel that already reaches the create_schema response. Co-Authored-By: Claude <[email protected]>
Code Review: PR #1794 — Read trailing type keywords as types, not part of the field nameReview Type: Initial Review Requirements Check
AssessmentThis is a net positive and I'd merge it in its current shape. The core judgement is right and unusually well argued: the commit message and the doc comments both state plainly that I verified the two claims the description makes that a reader would have to take on trust, and both hold:
My findings are about the blast radius of the rule, not its correctness. Nothing below blocks merge. Findings🟡 Important1. The
The mitigating fact — and the reason this is 🟡 not 🔴 — is that the reserved check at The design smell is that let candidate = head.join("_");
if RESERVED_CORE_PROPERTIES.contains(&candidate.as_str()) {
return None; // shortening would collide with a core property
}Principle: DRY / single source of truth for an invariant. One rule ("never shorten into a core property") replaces one table entry plus four unhandled cases, and it stays correct automatically when someone adds a core property later — the current keep-list would silently rot. 2. To be clear: I think a keep-list is correct here, for the reason the doc comment gives — the intent genuinely isn't in the phrase. My concern is calibration, not approach. Verified misses: The Worth noting the asymmetry in recoverability, because it's what makes this 🟡 rather than 🟢: a missed strip ( Maintainability of a hardcoded list: acceptable provided it stays a small curated table with the "why" comment it already has. It will drift, but the cost of drift is bounded and the alternative (asking the LLM to disambiguate, or requiring explicit 3. The message is consumed by an LLM agent, and it's emitted unconditionally on every successful strip. For a description like Principle: signal-to-noise — a warning that fires on success is not a warning. The content is good — naming the stored key and telling the caller to use it in templates/filters is exactly the actionable part. Two options, either is fine:
The second half of that suggestion matters: right now the warning tells the caller what happened but not how to override it. Naming the escape hatch (explicit 🟢 Suggestions4. 5. 6. Repeated / all-keyword names behave sanely — no action needed, recording it as verified. No panics, no empty names, no unicode mangling — 7. Interaction with Both extraction paths hand 8. Re: the known pre-existing TestingTests are the strongest part of this PR. Specifically worth calling out:
Gap: no test covers the strip-into-reserved-name interaction from 🟡-1. If you act on that finding, Standards Compliance✅ No lint suppression, no PerformanceNegligible. Recommendation: COMMENT — approve-with-suggestionsThe change is correct, well-reasoned, well-tested, and strictly better than what it replaces. None of the findings are blockers: 🟡-1's bad case still produces a loud warning rather than silent shadowing, 🟡-2 is a table that wants a few more rows, and 🟡-3 is polish on a message. My one recommendation if you address anything before merge is 🟡-1 — replacing the (Posted as a comment rather than an approval because GitHub rejects self-approval — the author and reviewer are the same account.) |
malibio
left a comment
There was a problem hiding this comment.
Initial pragmatic code review posted above: COMMENT (approve-with-suggestions). Net positive, no blockers. Verified 126/126 schema tests pass and independently probed ~45 edge cases through an extracted copy of the inference pipeline.
Three 🟡 findings, all non-blocking:
- Stripping can manufacture a reserved-core-property collision (
"status text"→status, alsopriority/content/id). Theduekeep-list entry solves exactly this for one word; a general "don't shorten into RESERVED_CORE_PROPERTIES" check would subsume it and cover the rest. - Keep-list omissions bias toward the expensive failure direction (
model number→model,ticket/flight/id). A wrong strip breaks user-visible keys; a missed strip is cosmetic. - Warning fires on every strip, including unambiguous ones, and doesn't name the override (explicit
fields).
Confirmed the two load-bearing claims: due_date is a real core task property (behaviors/mod.rs:724) and both due/due_date are in RESERVED_CORE_PROPERTIES; and the warnings channel does reach the create_schema response. No existing test was weakened — test_integration_full_schema_creation was tightened from substring to exact assertions, which is precisely the assertion that let the original bug hide.
Review follow-up. Shortening a name can only remove words, so it could land on a core property the caller's own wording avoided: "status text" describes a field `status_text`, but stripping produced `status`, colliding with a reserved core property that "status_text" never touched. Verified through the real parse pipeline for status/priority/content/id. strip_trailing_type_keyword now declines when the shortened name is in RESERVED_CORE_PROPERTIES. Checking there rather than enumerating each casualty in the keep-list keeps one source of truth, so a core property added later is covered without revisiting this function — the `due` entry was previously the only such case handled, and by hand. Also widens the intrinsic keep-list, since recoverability is asymmetric: a missed strip leaves a clumsy name, while a wrong strip changes a user-visible key that title templates, CEL selectors and query filters resolve against. Adds model/ticket/flight/id/security/registration/license/batch/lot/room/ seat/case to the "number" group, whose nouns have a number rather than being one. The strip warning now names the explicit-"fields" escape hatch. It still fires on every strip: the stored key differs from what the caller wrote, and the agent needs it for subsequent title-template and filter calls. Co-Authored-By: Claude <[email protected]>
Code Review: PR #1794 — Re-Review of
|
| # | Recommendation | Status |
|---|---|---|
| 🟡-1 | Express the "don't shorten into a reserved core property" invariant once, instead of enumerating due by hand |
✅ Addressed, exactly as suggested — verified load-bearing by mutation |
| 🟡-2 | Widen the number keep-list (model/ticket/flight/id/…) |
✅ Addressed (12 entries added) — but |
| 🟡-3 | Warning should name the escape hatch; consider not firing on unambiguous strips | ◐ Half addressed — escape hatch named (good); every-strip firing deliberately retained. Rebuttal assessed below, I accept it |
| 🟢-4 | Collapse redundant len() < 2 / head.last()? guards |
✅ Addressed |
| 🟢-5 | .find().is_some_and() → .any() |
✅ Addressed |
New issues introduced by this commit: 1 (🟡-A — test coverage gap on the new keep-list entries). No behavioural regressions found.
Requirements Check (issue #1789)
| # | Acceptance criterion | Status |
|---|---|---|
| 1 | Decide the inference rule, incl. names where the keyword is intrinsic | ✅ Rule now stated as three composable guards (final-word, keep-list, reserved), each documented at its definition |
| 2 | "capacity number" infers name capacity, type number |
✅ Re-verified end-to-end through the pipeline harness and via test_create_schema_paths_agree_on_stored_field_names_with_type_keyword |
| 3 | Intrinsic keywords not mangled — "invoice number" stays invoice_number |
✅ Upgraded from model number → model_number, ticket number → ticket_number, flight number → flight_number, social security number → social_security_number |
| 4 | A test asserts both routes agree on the stored name using a description containing the type keyword | ✅ Unchanged and still asserts on the persisted node |
| 5 | Existing tests updated to the decided rule | ✅ Extended, not weakened |
All five criteria now met. Criterion 3 was the one I could only pass partially last time.
Assessment
This is the right fix, and it's the version of 🟡-1 I'd hoped for rather than the cheap one. The author took the general invariant over the enumeration, and the commit message argues the choice on its merits rather than citing the review. Verified through the real pipeline that all four previously-unguarded cases are closed and that the strip is declined rather than performed:
"status text" -> status_text (was: status)
"priority text" -> priority_text (was: priority)
"content text" -> content_text (was: content)
"id number" -> id_number (was: id)
I also checked the cases I had not probed, and the general guard covers them for free — which is precisely the argument for preferring it: node type text → node_type_text, parent id text → parent_id_text, root id text → root_id_text, created at date → created_at_date, modified at date → modified_at_date. The hand-enumerated alternative would have missed all five. The DRY argument paid off immediately, not hypothetically.
Mutation check on the guard (independent of the main agent's): replacing if RESERVED_CORE_PROPERTIES.contains(...) with if false fails exactly two tests — test_parse_field_descriptions_does_not_strip_onto_reserved_property (mod.rs:1652) and test_strip_trailing_type_keyword (mod.rs:1599). Confirms the guard is load-bearing and the new tests are not vacuous. The pipeline-level test is the one that matters: it exercises parse_field_descriptions rather than the private helper, so it pins the behaviour and would survive a refactor that moved the check elsewhere.
Answering the three questions put to this re-review
1. Is declining the strip the right response, versus stripping and letting the reserved warning fire?
Declining is correct, and for a sharper reason than "avoids a collision". The two situations are not symmetric:
create_schema({description: "status"})— the caller described a reserved name. Warning is right: report what they asked for, leave the choice with them (normalize_inferred_fields's own doc comment commits to exactly this).create_schema({description: "status text"})— the caller describedstatus_text, which is not reserved. A strip-then-warn design would have the tool create the problem and then bill the caller for it. The warning would be truthful but the collision would be an artifact of our inference, not of their input.
Declining keeps the invariant "we never make a caller's name worse than they wrote it", which is the same asymmetry-of-recoverability argument the keep-list rests on. The two mechanisms now share one rationale instead of two. I'm satisfied this is the better of the two designs.
2. Does it interact correctly with the reserved warning at normalize_inferred_fields:1429? Is there a path where the caller gets no signal?
Interaction verified correct — the guard and the warning are disjoint by construction. The guard fires only when the shortened name is reserved; the warning fires only when the stored name is reserved. When the guard declines, the stored name is the unshortened one, which by definition is longer than the reserved candidate and therefore not itself reserved. So there is no double-warn, no suppressed warn, and no ordering hazard. Confirmed empirically — "status text" produces zero warnings, "status" produces exactly one, "due date" produces exactly one (unchanged from 271d8b31; the due keep-list entry already declined that strip, so this is not a regression).
On "is there now a path where the caller gets no signal about an unexpected stored name?" — no, because the stored name is no longer unexpected. When the guard declines, the stored name is what the caller literally wrote, normalized (status text → status_text). Silence is the correct signal: nothing surprising happened. The signal is owed when we change the name, and that path still warns.
3. Is the due entry in INTRINSIC_KEYWORD_PREFIXES now dead code?
No — it is genuinely load-bearing, and the author's instinct to keep it was right even though the stated reason is the weaker one. I tested this directly rather than reasoning about it. The guard checks head.join("_"), so it only subsumes the due entry when the head is exactly due. Multi-word heads ending in due escape it. Simulating removal of the entry:
payment_due_date -> Some("payment_due") // guard does NOT catch: "payment_due" not reserved
invoice_due_date -> Some("invoice_due") // likewise
rent_due_date -> Some("rent_due") // likewise
due_date -> None // guard DOES catch this one
With the entry present, all four correctly return None. So due covers a strictly larger set than the reserved guard does. payment_due_date → payment_due would be a real bad key on an Invoice schema. Keeping it is correct; the doc comment's framing ("documents intent independently") undersells it — it's not redundant documentation, it's the only thing handling the multi-word-head case. Nit: worth a word in the comment so a future reader doesn't delete it as dead code after making the same first-order analysis I did. birth is likewise live (date_of_birth is handled by word-order, birth_date by this entry).
Corollary worth noting: the same multi-word-head limitation applies generally — customer_id_number, order_id_number and user_id_number all correctly return None, but via the id keep-list entry, not via the reserved guard (customer_id is not reserved). Adding id to the keep-list was therefore not redundant with the guard either. The two mechanisms genuinely compose.
Findings
🟡 Important
A. 📁 packages/core/src/schema/mod.rs:1148-1159 — The 12 new keep-list entries are entirely untested. Removing all of them fails zero tests.
This is the one new issue. I ran the same mutation check on the widened list that I ran on the guard: deleting model, ticket, flight, security, registration, license, batch, lot, room, seat, case from INTRINSIC_KEYWORD_PREFIXES and re-running the suite gives 127 passed, 0 failed — an unchanged green suite. (id is separately covered by the new reserved-property test, so I excluded it from the deletion set.)
test_strip_trailing_type_keyword's intrinsic block (mod.rs:1569-1581) still lists only the original entries — invoice, phone, account, serial, order, tracking, part, page — and was not extended alongside the table. So the fix for 🟡-2 landed in the code but not in the test, and nothing prevents a future edit from silently reverting it.
Principle: a change worth making is worth pinning — untested data tables are the ones that rot. The irony is sharp here: 🟡-2 was raised because the original list's omissions were load-bearing and expensive to fix later, and the new entries now carry that same exposure. This is also the cheapest possible fix — the test already loops over a slice, so it's adding strings to an existing array, not writing a new test:
"model_number", "ticket_number", "flight_number", "registration_number",
"license_number", "batch_number", "room_number", "seat_number", "case_number",Not a merge blocker (the behaviour is correct today, and I verified all 12 work through the real pipeline), but it's the highest-value follow-up remaining on this PR and it costs one line.
🟢 Suggestions
B. 📁 packages/core/src/schema/mod.rs:1155-1157 — room, seat, case, lot block the number strip only; the same nouns still strip freely against other keywords.
Checking the over-blocking risk raised in the brief: the keep-list is keyed on (keyword, prefix) pairs, so widening the number group has no effect on any other keyword. Verified: room text → room, case text → case, case date → case, batch date → batch, lot text → lot all still strip correctly. A Venue's capacity is untouched — capacity number → capacity still works, since the pair is (number, capacity) and capacity is not in the list. So the specific concern about "room number" blocking a legitimate capacity strip does not materialise; the tuple keying contains the blast radius by design.
The residual judgement call is case and lot, which are the two genuinely ambiguous additions — a legal-tech schema's case number is an identifier (correctly kept), but lot number in an auction context could plausibly be an integer the user wants to sort on. Both fail in the recoverable direction (clumsy name, not a wrong key), which is the direction the doc comment explicitly chose. I'd leave them. Nit: no action.
C. 📁 packages/core/src/schema/mod.rs:1039-1043 — 🟡-3 rebuttal: sound, accept as-is.
The author kept the warning firing on every strip, arguing the stored key differs from what the caller wrote and the agent needs it for subsequent title-template and filter calls. I withdraw the finding. My original framing ("a warning that fires on success is not a warning") assumed the reader is a human triaging a log. The consumer here is an LLM composing a follow-up call, and for that reader the message isn't a warning about a problem — it's the return value telling it which key to use. "capacity number" → capacity is a correct inference and a fact the agent cannot derive from its own input. Suppressing it on the unambiguous cases would remove information precisely where the agent is most likely to assume nothing happened. The noise cost to the reserved-property warning is real but second-order, and the two messages are textually distinct enough not to blur.
The escape-hatch sentence is a genuine improvement and closes the actionable half of the original finding — the message now says what happened and how to override it. Nit: the phrasing "instead of a description" slightly overstates the requirement (fields and description can coexist; only the named field needs to move), but no agent is going to be misled into a broken call by it.
D. 📁 packages/core/src/schema/mod.rs:1176-1180 — 🟢-4 collapse is correct, and strictly better than what I suggested.
Folding words.len() < 2 into head.is_empty() on the post-split_last value removes the redundancy and the double source of truth about what "too short" means, rather than just annotating it. split_last()? on an empty vec still handles the "" input (verified: returns None). The surviving head.last()? at line 1181 is now genuinely infallible given head.is_empty() was checked three lines up — same overlap I flagged, one layer down — but it's inside a -> Option function where ? costs nothing and reads fine. Not worth another pass.
Testing
The pipeline-level test the previous review asked for was added and is the right shape — test_parse_field_descriptions_does_not_strip_onto_reserved_property (mod.rs:1649-1656) exercises parse_field_descriptions, not the private helper, and covers three distinct reserved names in one call so a partial regression can't pass. The doc comment above it explains why the case matters ("manufactures a collision rather than reporting one") rather than restating the assertion. The unit-level cases added to test_strip_trailing_type_keyword include due_date in both the intrinsic block and the new reserved block — deliberate overlap that pins the behaviour from both mechanisms, so removing either one alone is caught.
Gap: 🟡-A above. The guard is well pinned; the keep-list widening is not pinned at all.
Standards Compliance
✅ No lint suppression, no #[allow(dead_code)], no #[deprecated], no compat shims. ✅ No issue numbers in code comments — the #1789 reference stays in commit messages where it belongs. ✅ No new dependencies. ✅ Atomic: one cohesive purpose (review follow-up), single file, no drive-by edits. ✅ Comments explain why (the "manufactures a collision" comment at 1188-1191 and the asymmetric-recoverability rationale at 1130-1133 are both intent, not mechanics). ✅ No security surface — pure string manipulation, bounded allocation, no injection/authz/secrets dimension. ✅ Commit message argues the design rather than narrating the diff.
Performance
Unchanged and negligible. The new guard is one contains over an 11-element &[&str], on a path that already does DB I/O. The widened keep-list adds 12 entries to a linear scan that runs at most once per field.
Recommendation: COMMENT — approve-with-suggestions. Ready to merge.
6802414a addresses the substance of every finding from the previous review. 🟡-1 was fixed with the general invariant rather than the enumeration, and I verified it closes five cases beyond the four I originally reported — the DRY argument paid off immediately. 🟡-2 is fixed in behaviour. 🟡-3's rebuttal is sound and I withdraw the finding; the escape-hatch addition closes its actionable half. 🟢-4 and 🟢-5 are done. The due entry is not dead code — I tested it, and it covers multi-word heads (payment_due_date) that the reserved guard structurally cannot reach.
One new finding, non-blocking: 🟡-A, the 12 widened keep-list entries have zero test coverage — deleting them leaves the suite green. That's a one-line fix to an existing test loop and is the only thing I'd still do on this PR, but it doesn't hold up the merge given the behaviour is verified correct today. Issue #1789's acceptance criteria are now fully met, including criterion 3 which I could only pass partially before.
(Posted as a comment rather than an approval because GitHub rejects self-approval — the author and reviewer are the same account.)
malibio
left a comment
There was a problem hiding this comment.
Re-review of 6802414a posted above: all five prior findings addressed (🟡-1 fixed with the general invariant, 🟡-2 fixed in behaviour, 🟡-3 rebuttal accepted and withdrawn, 🟢-4/🟢-5 done). One new non-blocking finding — 🟡-A, the 12 widened keep-list entries have zero test coverage. Ready to merge.
Re-review follow-up. The keep-list was widened in the previous commit but the test still listed only the original entries, so deleting all twelve new ones left the suite green — an unexercised entry is indistinguishable from a missing one, since the strip just proceeds. Every entry is now asserted. Also corrects the reasoning recorded for `due`. It was kept as documentation of intent, on the assumption the reserved-property guard already covered it. It does not: the guard compares the whole shortened name, so it protects `due_date` but not `payment_due_date`, whose shortened form is the unreserved `payment_due`. The keep-list matches the word before the keyword, which is the only thing handling qualified heads — the same applies to `id` and `customer_id_number`. Both mutations now fail the suite. Co-Authored-By: Claude <[email protected]>
Closes #1789