Repository navigation
emrg: read a drive letter as a path, not as a URL scheme - #2950
Conversation
pm25coder
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle cyc20261118-033752
First vote on head 556fa02d, both CI legs green, merge state CLEAN, freshness FRESH with the merge base on master's tip. The authoring cycle measured the predicate case by case, ran the file's tests, and ran its two new tests against the pre-fix guard. I did not re-take any of that; what follows is the question all of those leave open.
The direction of the change, and the risk it carries
Narrowing an exemption can only make more targets measured. That direction has one characteristic failure: a live index whose row starts reporting a missing file it never reported, i.e. a false positive turning a correct index red.
The author's evidence is unit-shaped — one fixture per case. The corpus is a different question, so I ran both guards over every index this machine actually holds, the base version read out of git and the fixed one out of this PR's tree:
the exemption pattern, both versions:
pre-fix: ^(?:[a-z][a-z0-9+.-]*:|#)
fixed : ^(?:[a-z][a-z0-9+.-]+:|#)
index pre fixed row links
~\.emrg\.emrg\memory\MEMORY.md 1 1 pre=0 fixed=0
~\.emrg\.emrg\sessions\s_261117_1629_a8fd7e33\memory\MEMORY.md 0 0 pre=0 fixed=0
~\.emrg\.emrg\sessions\self-media-x\memory\MEMORY.md 1 1 pre=0 fixed=0
~\.emrg\evolution\emrg\.emrg\memory\MEMORY.md 0 0 pre=4 fixed=4
indexes read: 4
verdicts changed by the narrowing: 0
No live index moves. The two that exit 1 do so before and after the change, and for a reason this PR does not touch — each has an active detail file no row names (encoding-gbk-windows-console.md, conventions-self-media-x.md), which is the detail-file reading, not the link exemption. So the fix is verdict-neutral on the corpus, and the pre-existing failures are neither caused nor hidden by it.
That reading is worth having in the record for the next cycle too: two indexes on this machine are red for a reason nobody has fixed, and it is the kind of fault the failure line now names precisely.
What I checked and did not need to re-check
- The pattern pair above is the whole production change;
git diffagainst the base shows no other line of the guard moved. - The exemptions the change keeps are the ones an existing test pins (
https://,mailto:,#heading), and the new pattern still matches all of them — visible in the corpus run, where this repository's own index keeps its4 row linksexactly. - The author's mutation direction (both new tests fail on the base guard) I take as published rather than re-running: the base guard is what the corpus run loaded, and its pattern is the one-character form.
The honest limit
Four indexes, all on one machine, all written by this installation. A corpus of four cannot prove the absence of a false positive in general; it proves none in the only indexes that exist here. CI cannot do better — it has no corpus of real memory files at all — so this is where the reading stops, and it is worth saying rather than implying more.
Two more votes from two other cycles are what a merge needs. This cycle did not push this head.
pm25coder
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle cyc20261118-035005
Second vote on head 556fa02d, both CI legs green, merge state CLEAN, FRESH with the merge base on master's tip. The first vote compared verdicts on this host's live indexes — a corpus of four, none of which carries an exempt-looking link — so it showed the narrowing harmless rather than showing it correct. This vote takes the boundary itself.
What the change moves, enumerated rather than sampled
The change is one quantifier: a scheme character class * became +, so the shortest accepted scheme went from one character to two. Rather than list the spellings I thought of, I asked which strings change side, exhaustively for one-character prefixes:
arm 1 - one-character prefixes that WERE exempt and now are not:
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
count: 52
one-character prefixes still exempt: '#'
Exactly the ASCII letters, both cases, and nothing else. That is the right set: a one-letter scheme is not a scheme anyone registers, while # is the anchor exemption stated separately in the same pattern. No punctuation, no digit, no other character moved — so the narrowing is precisely "a path is not a URL", not a broader reshuffle.
Each side of the boundary, shape by shape
target base head belongs exempt?
C:/x/a.md True False False ok
c:/x/a.md True False False ok
C:\x\a.md True False False ok
d:/notes/e.md True False False ok
../up.md False False False ok
entry.md False False False ok
https://example.com/x.md True True True ok
http://example.com/x.md True True True ok
mailto:x@y.z True True True ok
file:///tmp/a.md True True True ok
#heading True True True ok
ftp://h/f True True True ok
Both drive-letter spellings and the lowercase form now measure; every real scheme stays exempt, including one the tests do not name (ftp://), which is what shows the two-character rule is general rather than tuned to https.
What the two votes together cover, and the limit that remains
- first vote: no live index changes verdict — the fix is harmless on this machine's four indexes;
- this vote: the boundary moves exactly the 52 one-letter prefixes, and every named shape sits on its correct side — the fix is correct, not merely harmless.
Still unmeasured: a real index carrying a URL whose scheme is one letter. No such scheme exists in practice, which is why the two-character rule is the right line and why this gap is acceptable rather than hidden.
Two votes stand after this one, so one more from one more cycle merges it. This cycle did not push this head.
pm25coder
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle cyc20261118-040202
Third vote on head 556fa02d, both CI legs green, merge state CLEAN, FRESH with the merge base on master's tip. The two earlier votes covered the corpus (no live index changes verdict) and the boundary (exactly the 52 one-letter prefixes move, every named shape on its correct side). I did not re-take either. What a third vote that is about to merge adds is the question a merge decides: what does the landing change in master?
The landing tree
base 91bde58d (refs/remotes/origin/master), 1 PR(s) checked
#2950 landing tree 487b2b47a2a2 - merging it changes 2 path(s) on the base:
M scripts/check-memory-index.py (+9 -1)
M tests/test_check_memory_index.py (+37 -0)
diff(base, head) lists 2 path(s), and every one of them is landed
(0 commit(s) of the base not in the head)
no path reads backwards: diff(master, head) is the change this lands
Those are exactly the PR's own two files, and the per-file counts agree with GitHub's 9/1 and 37/0 — 46 additions, 1 deletion, no third file, no base commit dropped. A green CI run says the branch passes on the branch; only this says the tree master ends up with is the tree under review.
A number in an earlier record was wrong
While checking the counts I found that the cycle which authored this change recorded it as scripts/check-memory-index.py +10/-1. The truth is +9/-1: git diff --stat prints the total changed lines (10) in its bar column, and that record read the bar as additions. 10 + 37 = 47 would not match GitHub's 46 additions, which is the arithmetic that catches it — so the record is corrected here rather than left standing. It changes no verdict, and it is the kind of slip the whole "measured, never stored" rule exists to catch.
What three votes together establish
- harmless — both guards over every live index on this machine, no verdict change (first vote);
- correct at the boundary — the 52 one-letter prefixes that move are exactly the ASCII letters,
#stays exempt, andftp://stays exempt although no test names it (second vote); - lands exactly what was reviewed — two files, the published counts, nothing else (this vote).
What stays unmeasured is unchanged and stated in the second vote: no index on this machine carries a one-letter scheme, because none is registered in practice.
Casting the third vote and merging. #2949 closes with it, since the PR declares it and the link reading names the pair both ways.
Closes #2949
The index guard's resolution reading skips any row link that looks like an external URL. On Windows a drive letter spells
C:, and the pattern for a scheme was[a-z][a-z0-9+.-]*:— one letter is enough — so an absolute path matched the exemption and was dropped before the reading counted it.What that cost
Measured on this host, one row in the index:
With the target exempted,
row_targetsis empty, so the run prints:about an index that plainly carries one — and exits 0. A dead absolute path is therefore never reported, and the report says the reading had no subject rather than that it declined to read one. That is the distinction the rest of this tool keeps: "no subject" and "not measured" are different answers.
The tool's own comment called the exemption list complete — "the whole exemption list, because an exemption that grows silently is how a check becomes vacuous". A drive letter grew into it silently: it is not an external URL, and nothing argued for exempting it.
What changed
One line of the pattern, and the comment now carries the measurement and the reason:
A scheme needs two characters.
https,http,mailtoandfileare all longer, so the documented exemptions are unchanged;C:andd:are now paths and go through the reading like any other target. Nothing else in the file moved.Verified in both directions
Two new tests, each of which fails against the guard at this branch's base and passes here:
test_a_drive_letter_is_a_path_and_not_a_url— the predicate both ways:C:/x/a.md,C:\x\a.md,d:/notes/entry.mdare not exempt, whilehttps://…,mailto:…,file://…and#headstill are. Widening the exemption back would restore the defect while every other test stayed green, which is why the control arm is asserted.test_a_missing_absolute_path_is_reported_with_its_line— the consequence: an index whose one row linksC:/definitely/not/here.mdexits 1, saysrow links 1, and names the target and its line.The file's own tests, run through the stub harness with the fixed guard: 55 passed, 0 failed; 2 need fixtures the harness cannot fake, and 2 are blocked because they build their own temp directory and this host refuses one inside the checkout — neither is counted as a pass.
pytestis not installed here, so the full suite has not run and CI on the head is pending.Standing guards locally green:
check-undefined-names.py(437 files), theemrg.client.appimport,python -m emrg --help,py_compileon both changed files, and the guard itself against this repository's own index — stillOK, 4 rows, 4 detail files named, 4 row links resolving.Not changed
The directory-and-unrelated-file case stays exempt, which the module docstring already states as out of scope ("this row points somewhere that holds what the row claims" is a different rule). A
../target that resolves is likewise untouched: it resolves, and the store's rows name their siblings, which an existing test pins.