fix(research): survive the #137 config layout, and anchor the flag rewrite - #1398
Open
TimeToBuildBob wants to merge 1 commit into
Open
fix(research): survive the #137 config layout, and anchor the flag rewrite#1398TimeToBuildBob wants to merge 1 commit into
TimeToBuildBob wants to merge 1 commit into
Conversation
…r the flag rewrite aw-watcher-window#137 moved the research knobs out of `default_config` into a separate `research_defaults` template, so they stop being persisted into every fresh install's config file. That is the right fix, but it removes both TOML table headers the Research Edition patch script anchors on. Two defects follow. 1. Injection breaks on the next submodule bump. `patch_config()` requires exactly one `[aw-watcher-window.research_category_map]` and one `[aw-watcher-window.research_app_category_map]` header. Neither exists past ActivityWatch#137, so the script aborts and the Research Edition build fails. The pin is currently a297914 (the ActivityWatch#136 merge), where both headers still exist -- so the build works today and breaks the moment anything, including a dependabot submodule bump, moves it forward. The fail-closed message would also misdiagnose it as 'submodule predates ActivityWatch#136' when the real cause is the opposite. 2. The flag rewrite could silently disable the Research Edition. ActivityWatch#137 documents the release-time rewrite in a comment containing the literal text `sed -i 's/^research_enabled = false$/research_enabled = true/'`, and that comment sits *above* the real flag. The unanchored `text.replace(..., 1)` therefore patches the comment and leaves `research_enabled = false`, producing a green build with research disabled and no error anywhere. Both layouts are now handled: post-ActivityWatch#137 the maps are injected into `research_defaults` with unprefixed headers (that template is parsed standalone and merged into the section key by key, so a prefixed header would create a nested key nothing reads); pre-ActivityWatch#137 the existing prefixed headers are used. The flag rewrite is line-anchored via regex, matching the contract ActivityWatch#137's own comment documents, and refuses to guess if it finds anything other than exactly one match. The pre-ActivityWatch#136 guard now keys on the runtime lookup `config.get("research_app_category_map"` rather than a table header, so it tests the capability that actually matters and survives further reshuffling of the config templates. Verified against both real config.py revisions: 570 category patterns and 72 app entries inject correctly, and the output parses as Python and as TOML in each.
Contributor
Greptile SummaryThe PR updates the Research Edition configuration patcher to support both watcher configuration layouts while safely targeting the effective feature flag.
Confidence Score: 5/5The PR appears safe to merge, with no concrete blocking or non-blocking defects identified in the changed paths. The patcher validates the unique effective flag and required app-map capability before handling each known configuration layout, while the expanded tests cover successful output and relevant failure modes. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Research Edition build] --> B[Load watcher config.py]
B --> C{Exactly one anchored disabled flag?}
C -->|No| X[Fail build]
C -->|Yes| D{App-map runtime lookup present?}
D -->|No| X
D -->|Yes| E{research_defaults template present?}
E -->|Yes| F[Enable flag and inject unprefixed maps]
E -->|No| G[Validate legacy prefixed tables]
G -->|Invalid| X
G -->|Valid| H[Enable flag and populate prefixed maps]
F --> I[Write patched watcher config]
H --> I
Reviews (1): Last reviewed commit: "fix(research): survive the #137 config l..." | Re-trigger Greptile |
TimeToBuildBob
force-pushed
the
fix/re-patch-config-shape
branch
from
August 17, 2026 22:20
922dcb3 to
c328757
Compare
This was referenced Aug 17, 2026
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.
Two defects in
scripts/patch_research_edition_config.py, both introduced by the interaction with ActivityWatch/aw-watcher-window#137. Neither is visible today, and both fire on the next submodule bump.#137 itself is right — moving research knobs out of
default_configstops them being persisted into the config of every user who is not in a study. It just removes the two TOML table headers this script anchors on.1. Injection breaks on the next submodule bump
patch_config()requires exactly one[aw-watcher-window.research_category_map]and one[aw-watcher-window.research_app_category_map]header. Past #137 neither exists, so the script aborts and the Research Edition build fails.Verified against both revisions of
aw_watcher_window/config.py:a297914(#136 merge — the current pin)a7690ac(aw-watcher-window master, #137)So the build works today purely because the pin has not moved. Anything that advances it — including a routine dependabot submodule bump — breaks it. The fail-closed message would then misdiagnose the cause as "submodule predates #136", which is the opposite of what happened.
2. The flag rewrite could silently disable the Research Edition
#137 documents the release-time rewrite in a comment containing the literal text:
That comment sits above the real flag. The existing unanchored
text.replace(enabled_line, ..., 1)therefore rewrites the comment and leavesresearch_enabled = false.That failure has no error and no failed step. It ships a signed Research Edition installer with the privacy filter off — to study participants. This is the one I'd want a second pair of eyes on.
Fix
research_defaultswith unprefixed headers — that template is parsed standalone and merged into the[aw-watcher-window]section key by key, so a prefixed header would create a nestedaw-watcher-windowkey that nothing reads. Pre-Wakatime supports browsers #137 the existing prefixed headers are used, unchanged.re.MULTILINE, matching the contract Wakatime supports browsers #137's own comment documents. It refuses to proceed on anything other than exactly one match rather than guessing.config.get("research_app_category_map"instead of a table header. That tests the capability that actually matters — whether the watcher can consume an app map — and survives further reshuffling of the config templates.Verification
Against the two real
config.pyrevisions, not just synthetic fixtures — both yieldresearch_enabled = true, 570 category patterns, 72 app entries, and output that parses as valid Python and valid TOML.Test suite rewritten to cover both layouts (7 tests, passing), including a regression test asserting the sed-example comment survives while the real flag flips. The previous fixtures omitted the runtime lookup that real
config.pyalways has, which is why they did not catch this.Context
This is on the critical path for a Lund University study build promised this week. Related: aw-watcher-window#136, #137, and #1397.