Conversation
Sixty-three hand-typed provenance prefixes, sixteen of them under a shorter spelling of the file name than the other forty-seven, become one constant the log lines interpolate. Grepping the logs for this file now finds all of its lines instead of three quarters of them.
Twenty-five copies of the same provenance prefix become one constant. The five that were plain strings become template literals, which puts them inside the reach of the log provenance scan for the first time.
Thirty-three copies of the same prefix become one constant.
Ten copies of the same prefix become one constant, including the cache sweep's origin field, which carries the same text into the sweep's own log lines.
Fourteen copies under two spellings of the file name become one constant under the path qualified spelling its neighbours use.
Seven copies of a bare file name become one constant, path qualified like the rest of the host layer. The lines still go out through the injected log port, so what the sweep's tests observe is unchanged.
Eight copies of a bare file name become one constant, path qualified like its neighbours.
Sixteen copies of the same prefix become one constant.
Ten copies of the same prefix become one constant.
Nine copies of the same prefix become one constant. All but one were plain strings, so they enter the log provenance scan for the first time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
One
LOG_PREFIXconstant per file, interpolated into the log lines, in the ten host files that carried more than one copy of their own provenance prefix. 195 hand-typed tags folded, and one spelling per file by construction. The name follows the three host files that already hoist theirs (backgroundHandlers.ts,optimumHandlers.ts,optimumManifest.ts); the renderer's twenty files call theirsLOG_TAG, and neither name changed here.src/ipc/handlers/gameHandlers.ts[back] [ipc] [gameHandlers.ts]src/ipc/handlers/modsHandlers.tssrc/ipc/handlers/pathsHandlers.tssrc/main/index.tssrc/config/configManager.ts[back] [config] [configManager.ts]src/ipc/adapters/modScan.tsoriginfield, which carries the same text into the sweep's linessrc/ipc/handlers/netHandlers.tssrc/ipc/handlers/utilsHandlers.tssrc/ipc/handlers/accountHandlers.tssrc/main/orphanedTempFiles.ts36 log lines change text, every one of them from a bare or short file name to the path qualified spelling its neighbours already used. Grepping
[back] [ipc] [ipc/handlers/gameHandlers.ts]now returns all 63 of that file's lines instead of 47.The line count is close to a wash (+215/-214), because each log line is rewritten rather than removed and ten files gain a declaration. The saving is the repeated literal itself: those ten files go from 204014 bytes to 199213.
Plain strings that carried a tag became template literals on the way, which is what pulls them inside the reach of
tests/log-provenance.test.tsfor the first time.What stays
src/ipc/network.tskeeps its two[back] [ipc] [network.ts]tags. Two lines and no concept removed is below the bar for a constant, even though the spelling is bare.catalogCache.ts,appUpdaterHandlers.ts,autoUpdaterEvents.ts,consoleTransportSafety.ts,shouldPreventClose.ts,updaterLogger.ts) keep their literal, which is what the issue's own order asks: one occurrence is not worth a constant.backgroundHandlers.ts,optimumHandlers.tsandoptimumManifest.tsalready hoisted theirs and are untouched.logMessage, the hexagonal split, the path policy, the IPC validation at the boundary, the mutation tested guards and the accessibility work.tests/log-provenance.test.ts,tests/security-boundaries.test.ts,tests/text-contrast.test.tsandtests/i18n/i18n-parity.test.tskeep their rules.Behaviour
No test file is touched and none is deleted. Before each commit, every tag carrying literal in the file was rendered back to plain text and diffed against the same rendering of the
origin/devversion. The only difference is the constant's own declaration, so the 36 short spellings are the sole text change and the other 159 lines come out byte identical.tests/log-provenance.test.tswas the one to watch. Its scan matcheslogMessage(,logMods(orwindow.api.utils.logMessage(followed by a template literal, so a per-file tagged wrapper would have quietly taken all these call sites out of it. The literal call shape is kept instead, and the scan grew rather than shrank: 261 matched calls and 293 interpolations ondev, 295 and 478 here.LOG_PREFIXends in "PREFIX", which is not on the risky word list, so the test passes untouched.origin/refactor/487-host-scaffoldingadds aCHANGE_PERMSdebug line topathsHandlers.tswith the prefix typed out.git merge-treereports no conflict between this branch and any of the eleven open branches, so whichever of the two lands second can fold that one line into the constant.Gate
npm run typechecknpm run lint:cireact-hooks/exhaustive-depsones asdev, none newnpm run format:checknpm run test:coveragedevThe three fractional gains are the ten new declarations, each one a covered statement.
Closes #488. Part of #492.