Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Extends the --strip-generated-meta build option to also remove noisy generated fields (version, timeUpdated) from compiled metadata files (filters.json, filters.js) to reduce irrelevant diffs during build comparisons (closes #1208).
Changes:
- Add stripping of
version/timeUpdatedfromfilters.jsonandfilters.jsduring the strip-generated-meta pass. - Update build output comparison messaging and developer documentation to reflect the new behavior.
- Add tests covering stripping behavior for
filters.json/filters.js.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/compare-build-output-against-master.sh | Updates report text to treat metadata diffs as meaningful rather than expected noise. |
| scripts/build/strip-generated-meta.ts | Adds JSON metadata stripping logic and expands the directory walk to target filters.json/filters.js. |
| scripts/build/build.js | Updates comment describing what --strip-generated-meta now removes. |
| scripts/build/tests/strip-generated-meta.test.ts | Adds unit tests for stripping version/timeUpdated from metadata files. |
| DEVELOPMENT.md | Documents expanded behavior of --strip-generated-meta. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (entry.name.endsWith(TXT_FILE_EXTENSION)) { | ||
| return (await stripGeneratedMeta(fullPath)) ? 1 : 0; | ||
| } | ||
| if (METADATA_FILE_NAMES.includes(entry.name)) { | ||
| return (await stripMetaFromMetadataFile(fullPath)) ? 1 : 0; | ||
| } | ||
| return 0; |
There was a problem hiding this comment.
This review doesn't seem important or has a lower priority because all the compiled .txt filters are under the filters/ directories, except for the local_script_rules.txt file located under each platform directory.
105th
left a comment
There was a problem hiding this comment.
AI Code Review (open-code-review)
Findings from an automated review of this PR (extends --strip-generated-meta to remove version/timeUpdated from filters.json/filters.js, closing #1208).
Summary: 5 findings — 4 medium, 1 low. No blocking (high) issues found. Main themes: (1) robustness of the new stripMetaFromMetadataFile against non-JSON/null inputs, (2) avoiding the exact formatting noise this PR aims to eliminate, and (3) a documentation label in compare-build-output-against-master.sh that will mislead for this PR's own validation run.
Details in the inline comments below.
| echo "" | ||
| echo "${C_BOLD}--- Metadata Files (informational) ---${C_RESET}" | ||
| echo "filters.json/filters.js diffs: $meta_diffs (version counter noise, not a regression)" | ||
| echo "filters.json/filters.js diffs: $meta_diffs (a nonzero count here signals a metadata change)" |
There was a problem hiding this comment.
The relabeled message claims a nonzero count always signals a true metadata change, but that holds only once master is rebuilt with this PR's strip logic. In this script the master worktree is built with its own pre-PR build.js/strip-generated-meta.ts, which strips only .txt files and still writes version/timeUpdated into filters.json/filters.js. So during this PR's own validation run, every filters.json/filters.js will differ purely from the strip asymmetry (master retains the fields, the feature branch deletes them) — producing a nonzero meta count that is exactly the version noise issue #1208 aims to eliminate, not a metadata change.
Recommendation: cover this transitional case, e.g. note that a nonzero count may be version/timeUpdated noise until master includes the metadata strip.
There was a problem hiding this comment.
As I understand it, the new specific content changes are only from $CHANGED_BRANCH and are not included in $BASED_BRANCH. Is my understanding correct? However, I've already added a step to sync the filters/ directory using git checkout $MASTER_SHA -- filters/.
This overwrites the changed worktree's filters/ (including revision.json) with master's exact content, so both worktrees compile from identical source.
105th
left a comment
There was a problem hiding this comment.
Reviewed the full diff (4 files; DEVELOPMENT.md skipped as docs). The stripping logic itself looks correct — metadata-file matching, the record-array guard, and the modified-file counting all check out, and the tab-indented serialization matches what @adguard/filters-compiler writes (both files are plain JSON, no trailing newline), so stripping is self-consistent for the compare workflow.
One blocking concern (a dead guard + a lost try/catch that can abort the build with a file-path-less error) and two test-coverage gaps below.
Minor (non-blocking): in the "clean file" case (strip-generated-meta.test.ts:171) consider asserting the file content stays byte-identical to pin the deliberate do-not-rewrite behavior.
105th
left a comment
There was a problem hiding this comment.
Code Review Summary
Ran an independent AI code review (ocr / open-code-review) on the full diff (5 files, +245/−19).
Verdict: No actionable issues found. The implementation is solid.
What this PR does
Extends --strip-generated-meta to also remove version/timeUpdated fields from filters.json/filters.js metadata files, in addition to the existing .txt meta-line stripping. Goal: clean, reproducible build-output diffs.
Verification highlights
filters.jsis strict JSON: Confirmed against the actual committedplatforms/cli/filters.jsandplatforms/cli/filters.json— both parse cleanly withJSON.parse(tab-indented, LF, no CRLF, contains realversion/timeUpdatedfields). The compiler emits strict JSON with a.jsextension, not a JS module, soJSON.parseis safe.- Robustness guards are correct:
isRecordArrayproperly excludesnulland arrays via!Array.isArray(item); the parsed value is checked for non-null/non-array before accessing.filters;try/catcharoundJSON.parserethrows with a contextual file-path message; missing/null/non-array/filtersand bad entries return0gracefully. - Formatting preserved:
JSON.stringify(data, null, '\t')matches the compiler's own tab indentation, and the trailing-newline is preserved viacontent.endsWith('\n')— no spurious full-file reformatting. - Test coverage is thorough: strips success, indentation/trailing-newline preservation, no-op on clean files, throw-on-invalid-JSON (file left untouched), missing/null/non-array
filters, null/array entries, and emptyfiltersarray.
Approved.
|
Thanks for your approval! I'd suggest just holding the current state until the parent PR is merged, rather than merging this into another PR. Since I'm following a stacked PR workflow (https://www.stacking.dev/), I'd like to keep each PR as a single commit when merging into master. |
|
Note on the This is expected, not a regression. Master's diff temp/platforms_master_build/mac/filters.json temp/platforms_changed_build/mac/filters.json
49,50d48
- "version": "2.1.8.22",
- "timeUpdated": "2026-08-21T19:13:03+0000",
64,65d61Once this feature is merged to master, the metadata-diff count against master will drop to 0 for unrelated branches. Until then, any branch compared against current master will show a nonzero count here. That's a known baseline mismatch, not a signal to investigate. |
|
Some of the phrases in the script interface are a little long.
=>
old files removed or not? If removed =>
=>
Long line, more readable as two => |
|
Since here is nighttime, I will apply your comment tomorrow morning. 💤 |
Was three: "stripped generated meta fields", "stripped metadata from N file(s)", and build.js's "Stripped generated meta from N file(s).". Align the two in this file on "stripped generated meta[ from N file(s)]". #1226 (comment)
The only module-level list without immutability typing. `readonly string[]` (not `as const`, which would break `.includes(entry.name)`). #1226 (comment)
"preserves tab indentation and trailing-newline from filters.json and filters.js" only wrote filters.json — writeMetadataFiles fell back to its `['filters.json']` default. Pass both names and assert each output is byte-identical to the expected serialization. #1226 (comment)
- rename the `testFile` fixture to `testFilePath`; it holds a full path, like its `oldFilePath` / `newFilePath` siblings - fold the standalone empty-`filters`-array case into the adjacent table-driven missing/null/non-array test so the skip contract lives in one place #1226 (comment) #1226 (comment)
maximtop
left a comment
There was a problem hiding this comment.
Independently validated findings from a multi-agent review. Only confirmed, non-duplicate issues are included.
What does the above mean? I didn't see any specific feedback in the code review to go off of. |
never mind, the agent went rogue |
|
I see. I'm waiting your additional reviews and approval 👀 |
maximtop
left a comment
There was a problem hiding this comment.
No further comments from me. Ready to merge.
after #1211? |
|
👀 Right. This PR will merge after down(parent) stack PR merged. |
`yarn strip-generated-meta` with no argument walked the tracked `platforms/` tree and rewrote files in place. Since this PR the pass also strips version/timeUpdated from the 32 committed filters.json/filters.js, so a stray `git add -A` after a bare run would ship metadata the products read, with nothing in CI to catch it. Drop the default: the CLI now needs an explicit target and errors on a missing dir; the single-dir path replaces the old Promise.all/filter machinery. The --strip-generated-meta build flag is unaffected — build.js passes its own root. Document the standalone command in DEVELOPMENT.md, fix the stale "metadata lines" wording in the Command Compatibility list, and note the required <dir> in the AGENTS.md command table. #1226 (comment) #1226 (comment) #1226 (comment)
A `%` in a filename prints an invalid format character error and truncates the entry, and backslashes get re-interpreted. printf '%b\n' "$diff_list" did the same \n expansion with the data as an argument. Squashed from PR #1226 review-fixup commits: 98315a702836c7a5643c9a8f6851deaad6cb8ef #1226 (comment)
a6fba14 to
8ab7ce1
Compare
|
This PR includes commits from #1212 due to a rebase a few weeks ago. I've squashed the commits by catalog, so please take another look when you have a chance. Note: I discovered an issue where the metadata verdict is only FAILED when running in normal build mode. |
Ensure metadata (groups/tags/locales) is available during cached builds. Previously, the compiler skipped metadata generation because the source files weren't present, leading to false PASS results in diff checks. Fix: Copy groups/tags/locales alongside filters_cached/ before cached builds and clean them up afterward.
|
Fixed the One thing still shows up in the verdict — the "N metadata file(s) differ" — but that's not new, it's the same transitional mismatch I flagged earlier in #1226 (comment): master doesn't have this PR's To reproduce cleanly without that noise, run |
105th
left a comment
There was a problem hiding this comment.
approving — the strip logic looks right, and the metadata gate asymmetry is already tracked in the thread above
Extends
--strip-generated-meta(previously.txtonly) to also drop these noisy fields from compiled metadata files. Closes #1208.