Repository navigation
fix(cache): extract shared date patterns to internal/dates and drop false positives - #1511
Conversation
okwasniewski
left a comment
There was a problem hiding this comment.
Automated review (thermo-nuclear pass by an agent on behalf of the maintainers). A human will take the final look.
Thanks for picking up the MONTH/DAY reuse from #1498.
Verdict: changes needed. The regexes are correct. Behavior is identical to main for every English month form, ordinals match in both orders, and the [a-z]* false positives (Marketing 12, Mayor 3, Augusta 3, 12 Marketing) are gone. Reverting each regex line on its own fails a test. Unit tests pass (45/45 in trace-anchors + agent-derived).
Merge order: #1498 (the original fix for #1496, by @21prnv) is in the merge queue. The two deltaMismatch tests here are copied verbatim from it, so please rebase on main once it lands, drop the duplicated tests, and keep this PR as the follow-up refactor.
Must fix
tests/unit/trace-anchors.test.ts:190-192:Marketing 1st/Decision 2nd/Octane 3rd genalready pass on main (main's\d{1,2}\bnever matched an ordinal), so they don't prove the false-positive fix. Use inputs main actually matches:Marketing 12,Mayor 3,Augusta 3,12 Marketing..changeset/unify-date-anchor-patterns.md: names internals (MONTH,DAY,cache/anchors.ts). Write it for users, e.g. "A replay no longer skips text likeMarketing 12as a date when checking its end state."- Ownership of the patterns: exporting regex source fragments from
agent/derived.ts(model-derived value detection) makes that module the owner of date parsing for the cache. Move them to a small neutral module (e.g.src/internal/dates.ts) that both files import. Both files also duplicate the ISO date and clock-time regexes today, so those can move too. - Silent regression: main's
[a-z]*caught some non-English month names by accident (3 septembre,Octobre 3,Juni 3,Marzo 3). With this PR they are no longer volatile. That's the safe direction (a cache handoff, not a false pass), but call it out in the PR body.
Nits
anchors.ts: theRedactedNodeimport move is unrelated churn, please revert it.
3430754 to
addf08c
Compare
|
Thanks for the review @okwasniewski! All points addressed:
|
okwasniewski
left a comment
There was a problem hiding this comment.
Automated review (agent-run thermo-nuclear review, a human maintainer reviews before merge).
Thanks, all 5 asks are done: rebased with no duplicate tests, the new false-positive tests fail on main (4 vs 8) and pass here, the changeset is user-facing, patterns live in internal/dates.ts, and the non-English note is in the body. Compared old and new patterns on ~90 inputs: nothing new matches in anchors.ts, only the intended English false positives and non-English months drop out. Restoring the loose [a-z]* prefix fails both the anchors and derived tests.
One must-fix:
packages/e2e/src/internal/dates.ts:4,7:MONTHandDAYare exported but nothing imports them.fallow dead-codeinspecexits 1 with "Unused exports (2)" (spec hasn't run yet, fork CI is waiting on approval). Dropexportfrom both.
Worth knowing:
derived.tschanges slightly: the old patterns had a literal space between month, day and year, and the shared ones use\s+, soOct 26,Oct\t26and26\nOctnow count as dates inderivedReason, which tests the raw typed value. That's fine, but say so in the body since it reads as a no-op forderived.ts.
Nits:
derived.ts:115-117: three blank lines left whereMONTH/DAYwere. Collapse to one.dates.ts:1: drop the consumer list from the header, "Date and clock-time patterns." is enough.
addf08c to
cd88bda
Compare
|
Thanks @okwasniewski! Updated:
|
|
Automated review (Claude, on behalf of @okwasniewski). Re-reviewed cd88bda. All asks done: Optional nits, not blocking:
Fork CI still needs maintainer approval to run. Labeling Ready for Human Review. |
Addressed, see re-review comment.
|
Saw on #1460 that a cache rewrite is planned. Does this PR still make sense to land before it, or would you rather I close it in favour of the rewrite? |
|
yeah, lets land it - we have cache rewrite planned but not yet started. |
What and why
Follow-up to #1496 and #1498 addressing maintainer review feedback:
ISO_DATE,CLOCK_TIME,MONTH_DAY_DATE,DAY_MONTH_DATE) into neutralsrc/internal/dates.ts, shared by bothagent/derived.tsandcache/anchors.ts. KeptMONTHandDAYunexported to avoid unused exports.main(now containing fix(cache): read a date with an ordinal suffix as a date #1498) and dropped duplicateddeltaMismatchtests.anchors.tsand collapsed blank lines inderived.ts.Marketing 12,Mayor 3,Augusta 3,12 Marketing) which previously matched due to loose[a-z]*month prefixes.packages/e2e/tests/unit/trace-anchors.test.tswith inputs that main actually matched to prove the fix..changeset/unify-date-anchor-patterns.md.[a-z]*pattern previously matched some non-English month words by accident (e.g.3 septembre,Octobre 3,Juni 3,Marzo 3). With this change they are no longer treated as volatile text anchors (leading safely to a cache handoff rather than a false pass).derived.tsspacing: The shared pattern uses\s+instead of the previous single space between month, day, and year, so inputs with multiple spaces or whitespace tabs (e.g.Oct 26,Oct\t26,26\nOct) now also count as dates inderivedReason.Issue
Follow-up refactor to #1496 / #1498
Verified
Ran regression checks covering:
Marketing 12,Mayor 3,Augusta 3, and12 Marketing.packages/e2e/tests/unit/trace-anchors.test.tsandagent/derived.tsintegration.Checklist
pnpm changeset) for any change to a published package