Repository navigation
fix: precheck_file matches ./ and absolute paths; get_issue accepts unpadded IDs - #26
Conversation
precheck_file accepts a project-relative or absolute path, but events were matched by exact string, so ./src/auth.py or the absolute path came back "Safe to modify" past failed attempts and open issues on src/auth.py. Normalize both the checked path and event paths to project-relative.
The field says '42' works, but get_issue('1') found nothing; it now uses
normalize_issue_id like record_fix. A non-numeric ID such as '*' returned
an arbitrary issue and now returns 'No issue found'.
|
Hi @riponcm, just checking this one is still on your radar. It's still mergeable, and the new tests in |
|
Thanks for the fix and for the nudge, and sorry for the wait. I reproduced both bugs on main: the same file gives 2 warnings as |
riponcm
left a comment
There was a problem hiding this comment.
Thanks again. Both fixes are right, and your 4 tests are exactly the reproductions I'd want: they fail on main and pass here, and the full suite is green. A second reviewer and I went through it, and four things need changing before merge:
- Speed.
_events_for_filenow callsproject_relativefor every path of every event, once per checked file, and absolute paths go throughresolve(). On a 3,000-event log with some absolute paths, matching 5 files went from 14 ms to about 1 s, andpjm precheckfrom 0.7 s to 1.8 s. Precheck runs before every edit, and 0.3.3 made it flat in project size, so please normalize each event's paths once per call, with a dict cache or an index built in one pass, and resolve the root only once. legacy_XXXXissue ids.pjm initruns backfill, which creates ids likelegacy_f436. The newisdecimal()check makesget_issuerefuse them, whilepjm fixstill accepts them. Keeping the glob safe with a shape check such asre.fullmatch(r"[\w-]+", wanted)would cover both. Please add alegacy_case to the test.- Windows absolute paths.
posixpath.isabs("C:/proj/src/a.py")isFalse, so on a Windows server a drive-letter path is never made project-relative and still comes back "Safe to modify".is_memory_pathjust above handles this with_WINDOWS_DRIVE; the same check works here. - Stale check.
staleness.location_filestill returns the raw location, so a decision stored with an absolute path is flagged bypjm briefbut not by precheck's staleness check forsrc/auth.py. Running it throughproject_relativekeeps the two consistent.
Smaller, at your discretion: the project root's own absolute path normalizes to "." and then matches any event whose summary contains a period; two spellings of one file produce duplicate warnings, which deduping after normalization fixes; and project_relative and is_memory_path could share one anchoring helper so they can't drift apart.
Happy to help with any of it. Once these are in, I'll merge it for 0.3.5.
…ive paths, stale check
- Speed: each event's paths are normalized once per call (cached per
distinct raw path) and the root is resolved once; find_stale_events
judges each distinct location once too.
- get_issue accepts any ID-shaped input ([\w-]+), so backfill's
legacy_XXXX ids work again while globs stay out.
- project_relative anchors Windows drive-letter paths.
- staleness.location_file returns the project-relative spelling, so
precheck and brief agree on a decision logged with an absolute path.
- The project root (".") is never checked as a file, and two spellings
of one file warn once.
- is_memory_path and project_relative share one anchoring helper.
|
Thanks for the careful review. All four are in fb5542b, plus the three smaller ones.
Smaller ones:
Tests: 7 new, and all of them fail on the previous head. Full suite 368 passed (361 before). Ruff output is unchanged on the touched files. |
riponcm
left a comment
There was a problem hiding this comment.
Thanks, this is excellent. I re-ran everything on my side:
- Speed: at 3,000 events, precheck now takes 163 ms, against 663 ms on main.
- Paths: every spelling of a path gives the same warnings, including
./, absolute, a symlinked folder, backslashes andsrc/../. - IDs:
legacy_IDs resolve, and glob characters are refused. - Tests: all 7 new tests fail on the previous head, and 368 pass on Python 3.10–3.14.
Approving. This ships in 0.3.5.
|
Thanks @riponcm, and the second reviewer, for the careful review and for re-running the speed numbers (163 ms vs 663 ms at 3,000 events). Glad it's in! |
Two small input-normalization fixes in the MCP tools. Each tool's field description already promises the input form that currently fails.
1.
precheck_filesays "Safe to modify" for./and absolute pathsThe
file_pathfield says "Project-relative or absolute file path to check", but_events_for_filecompares raw strings. With 3 failed attempts and an open issue logged atsrc/auth.py:file_pathsrc/auth.py[BLOCK] What already failed here (3 attempts)+ open issue./src/auth.pyno warnings. Safe to modify.src/auth.py/abs/path/to/proj/src/auth.pyno warnings. Safe to modify.src/auth.pyIt also fails the other way round: an issue logged with an absolute
locationwas missed byprecheck_file("src/db.py").Fix: a small
project_relative()helper next tois_memory_pathinstaleness.py. It folds./and..withnormpath, and turns an absolute path inside the root into a project-relative one, resolving it too for macOS/tmpand symlinked folders._analyze_filesapplies it to the checked paths, and_events_for_fileapplies it toe.filesand the location file. Paths outside the project are left as they are.2.
get_issuerejects unpadded IDsThe field says "Numeric strings without padding (e.g., '42') are also accepted", but
get_issue("1")returnedNo issue found with ID 1., because the raw input went straight intoglob(f"{issue_id}-*.md"). That also meantget_issue("*")returned whichever issue file came first.Fix: normalize with the existing
normalize_issue_id, the same helperrecord_fixuses. An ID that is still not numeric after that returns the usual "No issue found" message, so it never reaches the glob.Tests
Four new stdio tests in
tests/test_mcp_server.py: the three path spellings, an event logged with an absolute path, andget_issuewith0001/1/01/#1plus*and a missing ID. All 4 fail onmain(e49dd0c) and pass with this change. The full suite passes: 361 tests, Python 3.12, macOS.