fix: replace the home and profile folders exactly in the Journal, scrub repair_migrations (#497) #512

Merged
maximus merged 7 commits from issue-497-journal-exact-folders into main 2026-10-28 01:45:03 +00:00

7 commits

Author SHA1 Message Date
le king fu
eecbd2b626 fix: a period that ends a sentence also ends the known folder (#497)
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m24s
PR Check — Rust / rust (pull_request) Successful in 4m40s
The boundary after a known folder counted any "." as part of a name, so
"cannot open /home/max." kept the home folder, and withoutFolders would
then have kept its last segment, the user name. A "." now continues the
name only when a letter, mark, digit, "_" or "-" follows it:
/home/max.old and /home/max.2 stay, "/home/max." becomes "~.".

Found by the author's self-review.

Resolves #497

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 21:43:08 -04:00
le king fu
aafa63fac1 docs(adr): the measure of PR #491 holds for paths with a recognized start (#497)
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m30s
PR Check — Rust / rust (pull_request) Successful in 4m10s
Wording of review 27245: the 300 000 random lines are not all of that
shape; the measure is what holds for the paths that have one.

Resolves #497

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 21:41:31 -04:00
le king fu
3193adaa51 docs(state): manual check of the Journal without folders (#497)
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m25s
PR Check — Rust / rust (pull_request) Successful in 4m11s
One sub-bullet at the end of the checks due at the next release: on a
secondary test profile under Linux and Windows, a folder in place of
its database makes the opening fail, and the "Migration repair failed"
and "database preparation failed" lines must name the file without any
segment of the home folder, in the Journal, in what "Copy" copies and
in a test feedback (PR #512).

Resolves #497

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 21:38:06 -04:00
le king fu
c0f1447dff docs: the two curtains of the Journal and logFolders.ts (#497)
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 2m29s
PR Check — Rust / rust (pull_request) Successful in 4m6s
ADR 0021, section 7, now describes the exact curtain (the home and
profile folders, replaced in every entry, what it leaves: other
folders, subfolder names, 8.3 names, a line of db.ts already cut by the
heuristic before late folders), then the heuristic, its stops and its
two limits, with the corrections of review 27245 of PR #491: a path
glued to a character outside BEFORE_START has no recognized start and
can start from the home folder, and #478 adds rare cases to that limit;
"(" and the backtick open a new path too, and a blank in a following
folder leaves its words; a double quote and a line break keep the
suffix. The startup delay also covers the wait for the folders.

docs/architecture.md: logFolders.ts in the services table (22, and 28
services in the tree), the wait inside the section of connectToProfile,
cleanLogLine for every line of db.ts, the replacement and the replay in
logService, scrub in repair_migrations, what send_feedback carries, the
injected logError of the startup. CLAUDE.md counts 28 services.
CHANGELOG: one Fixed entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 21:33:32 -04:00
le king fu
66d687f1c2 test: pin cleanLogLine at each of the four Journal sites of db.ts (#497)
A path glued to ";" keeps "jean" through withoutFolders alone: one test
per site (failed close, failed checksum repair, stopped catch-up and
its copy, failed preparation) turns red if that site goes back to the
heuristic alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 21:25:28 -04:00
le king fu
c1d69d23c5 fix: replace the home and profile folders exactly in the Journal (#497)
withoutFolders guesses where a path starts and ends, and five review
passes each found a line it let a folder through: blanks, soft stops, a
kept stop in a folder name, the fallback after a cut, a path glued to a
character that starts nothing. The new src/services/logFolders.ts knows
the two folders that hold the OS user name instead: the home folder
(homeDir) becomes "~" and the folder of the profile databases
(appConfigDir) "<profile folder>", the latter first.

- replaceKnownFolders: either separator and any run of them between
  segments (JSON.stringify doubles each backslash), case ignored with a
  drive letter, trailing separator of the folder dropped, and a
  boundary after it, so /home/max leaves /home/maxime alone. Never
  throws.
- setKnownFolders builds the patterns once, every segment escaped
  (CWE-185: a raw "(" would make every captured console call throw),
  and ignores an empty or root folder.
- initKnownFolders resolves both folders once, independently
  (Promise.allSettled), never rejected; knownFoldersReady resolves when
  they are known or 2 s after initKnownFolders, and at once when it was
  never called.

logService replaces them in every entry, whatever its channel, and
replayLogEntries rewrites the entries written before they arrived,
sessionStorage included; main.tsx wires it right after initLogCapture.
db.ts waits for knownFoldersReady inside the exclusive section of
connectToProfile, before repair_migrations, and its four sites clean a
line with cleanLogLine: the exact folders, then withoutFolders, which
does not change. "Migration checksums repaired for" goes through
logWarn, and startupConnection writes through a logError that App.tsx
passes: neither file writes to the Journal through console.* any more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 21:24:35 -04:00
le king fu
e3e043644d fix: scrub the errors of repair_migrations through repair_at (#497)
repair_migrations built its two errors without scrub: rusqlite appends
the full path of a database it cannot open, so "Cannot open database"
carried the profile folder, and the OS user name with it, to the
Journal. The body moves to repair_at(db_path), which passes every error
it returns through scrub once, at its exit, with the database's parent
folder; the command resolves the path, then calls it.

The test replaces the database file with a folder of the same name: the
exists() guard passes and rusqlite fails to open it even as root, where
a read-only file would simply open read-only. It first checks that
rusqlite's own message names the folder, then that repair_at's error
names the file and <profile folder>, and no segment of the folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 21:24:25 -04:00