Skip to content

test(ci): the duplication-guard explain tests no longer read the real /tmp logs (#17377) - #21817

Merged
mrveiss merged 10 commits into
mainfrom
issue-17377-one-engine
Nov 19, 2026
Merged

mrveiss merged 10 commits into
mainfrom
issue-17377-one-engine

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Thinking Path

This PR was opened for an existing branch that never had one (triage status UNFINISHED). The branch carries 5ahead commit(s) of work not on main, linked to #17377 (The Python and shell size gates duplicate ~90% of their logic, and the Python ratchet test's monkeypatching blocks the obvious fix). It still needs a conflict sync with main and a review before it can merge. Acceptance criteria have not been verified against this branch.

What Changed

Commits on the branch (not on main):

Diff summary: 9 files changed, 835 insertions(+), 657 deletions(-)

Verification

Not yet verified. No CI evidence: this is a draft; no CI has run on it yet, and it needs a conflict sync with main and a review first.

Model Used

Branch authored by earlier Claude sessions; PR opened by Claude Sonnet 5.5.

Refs #17377

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Improved test isolation by assigning each run its own temporary log locations, while preserving the ability to override them.
    • Added coverage confirming that an unrelated pre-existing log file is not counted as a captured log or reported as an overage.

…ation (#17377)

tools/lint/file_size_engine.py holds the ratchet once: enumeration, line
count, three-way verdict, unmeasured/vanished/reach findings, the audit and
the commit path. scripts/check_{python,shell,frontend}_file_size.py are now a
GateConfig plus thin delegations, built from module globals at call time and
passing their own collaborators in, so every monkeypatch in the ratchet and
parity tests is still obeyed. Rebuilt on current main rather than revived:
the frontend gate (#17885) landed separately and is folded in here, and the
shared configure_logging from _scan_helpers is kept.

Output parity: 19 invocations across the three gates (audit, real files,
oversized/missing fixtures, excluded paths, cwd-relative runs from scripts/,
--help, bad flags) produce byte-identical stdout/stderr and exit codes to
origin/main. Two per-gate differences that were outside #17377's enumerated
surface are kept as explicit config rather than unified: the summary noun
(files vs file(s)) and whether the commit path skips excluded prefixes
(python never did, and resolves against cwd; shell/frontend do, against
repo_root).

repo_tests/one_file_size_engine_17377_test.py fails any scripts/check_*
size gate that does not import the engine, or that compares against the
limit, opens a file or spawns a process, or spells a ratchet finding outside
a docstring. AST-based, with a thin/forked contrast pair; main's three gate
versions each trip it with 14 findings.
…module patches (#17377)

AC3. The six audit tests that did monkeypatch.setattr(hook, ...) on
repo_root, KNOWN_LARGE, tracked_python_files and audit_ceilings now take the
gate's real GateConfig (hook._config(), varied with dataclasses.replace) and
call engine.audit_tracked / engine.run_audit with a tmp root and an explicit
file list. engine.audit_tracked is the new seam: the audit over a given list
with the engine's own scanner. Zero monkeypatch calls remain in the file.

Each rewritten test was shown to fail against a deliberately broken engine
(six breaks applied to a temporary copy, restored byte-identical, 31 passed
after):
  B1 no plain-limit verdict  -> discovers_an_unlisted_oversized_file
  B2 over-ceiling passes     -> surfaces_a_ceiling_violation
  B3 vanished pass dropped   -> reports_a_vanished_entry
  B4 reach floor ignored     -> fails_when_the_scan_reached_nothing
  B5 problems swallowed      -> 5 of 6, incl. problems_are_reported
  B6 scan flags every file   -> clean_for_an_unlisted_compliant_file
…> 11604 and 2831 -> 2830 (#17377)

Measured with this workflow's exact flags and jscpd 5.0.6 (the version CI
pins), over git-archive exports of origin/main and of this branch:

  main scope: 11,604 dup lines, 672 clones, 1,603,884 lines -- base and branch identical
  SLM scope:   2,830 dup lines, 123 clones,   265,516 lines -- base and branch identical

The figures are the same on both trees, so this lowering is reclaimed slack
from other merges, not a reduction made by the consolidation: the size gates
live in scripts/ and tools/lint/, which neither scope scans. The comment says
so, so the next reader can tell the two apart.
…scripts/ (#17377)

Owner decision: widen the main scope to the repo's own tooling, so the
size-gate consolidation (and any future fork there) is measurable at all.

MAX_DUP_LINES 11604 -> 11881. The pin RISES only because the scope widened;
against the same scope it falls. Measured with this workflow's exact flags and
jscpd 5.0.6 (the CI pin) over git-archive exports, widened scope on both:

  (a) origin/main  12,108 dup lines, 694 clones, 1,638,816 lines, 4,475 files
  (b) this branch  11,881 dup lines, 686 clones, 1,638,643 lines, 4,476 files

The 227-line drop is the size gates alone: clones among
scripts/check_*_file_size.py went 12 -> 4 (318 -> 83 clone lines), and the
clone set outside those files is identical between (a) and (b). The
workflow's own scan steps, run locally over (b), print 11881 against an 11881
pin (rc 0) and 2830 against 2830 for the unchanged SLM scope. Nothing gates a
raised pin yet (#16393), so the scope change and both figures are stated in
the workflow comment.

The scope is now stated once: MAIN_SCOPE_DIRS / SLM_SCOPE_DIRS in the job env,
read by both scan steps and by "Explain failure". The paths: triggers cannot
read env, so duplication_guard_scope_is_stated_once_17377_test.py asserts the
pull_request and push trigger lists name exactly the scanned trees, with a
contrast pair for each direction of drift. The names-the-failing-scope test
now derives its scope labels from the same env instead of restating them.
… /tmp logs (#17377)

test_a_missing_log_reports_no_figure_rather_than_a_guessed_one asserted the
"no captured log" path, but the step it runs defaulted to /tmp/main-dup.log
and /tmp/slm-gate.log -- files any local scan leaves behind. With them
present the test measured a real log and failed, so its verdict depended on
the machine, not the code.

The log paths are now stated once, as MAIN_LOG / SLM_LOG in the job env, and
the scan's tee, its gate call and "Explain failure" all read them (each was
a separate /tmp literal before; scripts/duplication_gate.py takes the path as
an argument and holds none). _run_explain gives every run its own empty
TemporaryDirectory for both logs, and the scope test pins that the steps tee
and gate through the env values.

Proof, with both /tmp files created first: the rewritten test passes
(1 passed; whole file 14 passed), and the previous version of the same test
fails against the same files (1 failed). The files were then removed.
@mrveiss mrveiss added the phase:M4.8 Shrink the symbol-fork baseline label Nov 18, 2026
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The test helper now sets default gate log paths inside a temporary directory. A regression test creates a stray log and checks that it does not produce a captured-log measurement or overage.

Changes: Log isolation

Layer / File(s) Summary
Isolated log paths and regression test
repo_tests/duplication_guard_names_the_failing_scope_test.py
_run_explain sets five default gate log paths inside a temporary directory. Values in extra_env can override these defaults. A new test creates /tmp/main-dup.log exclusively, skips if it already exists, and removes the created file. The test checks that the stray log does not produce a captured-log measurement or overage.
Merge Risk: Minimal · up to 70f69

Merge Risk: ⚪ Minimal · up to 70f69

This change only isolates test logs so the explain-test verdict no longer depends on stray files in /tmp. It has no production impact, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title says the duplication-guard explain tests no longer read the real /tmp logs. The raw summary confirms that _run_explain now uses a temporary directory for the five default log paths, and that…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title says the duplication-guard explain tests no longer read the real /tmp logs. The raw summary confirms that _run_explain now uses a temporary directory for the five default log paths, and that a new test checks a stray /tmp/main-dup.log does not affect the result. The title matches the main change. The objectives also describe this same isolation goal. The title cites issue number #17377, while the objectives cite PR #21817; this mismatch does not change the title's relevance to the change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d394052 and 90a0ec7.

Files selected for processing: 1

  • repo_tests/duplication_guard_names_the_failing_scope_test.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

Auto-sync: merging main into issue-17377-one-engine conflicts

The sync aborted the merge and pushed nothing. Conflicts are information, so it never resolves one itself. Below, for each conflicted file, are the commits that touched it on each side since the merge base 38c62a97b8. Merge main in yourself and push; the label clears on the first run that finds this branch 0 behind.

.github/workflows/duplication-guard.yml

side commit subject issue refs
main bfed335ff3 fix(ci): every job that runs repo python sets up the .python-version floor (#20903) #20903
main e3c3ffbe8e fix(toolchain): review -- install.sh's minimum Node is the engines floor, the range check reads partial and hyphen ranges and fails closed, and the stale Node 20 comments name the home (#19328) #19328
main d8b4a84aed dedup(toolchain): the Node.js major has one home -- the repo-root .nvmrc (22, maintainer decision); workflows read it, installers, Ansible, Dockerfiles and the sandbox image pin one guarded copy each (#19328) #19328
main 00b80975d0 fix(ci): the three 18559 failure reports take overridable log paths and are tested (#18559) #18559
main 66583b7d2e ci(duplication-guard): pins move to a data file, PAT-only bot PR, trigger coverage per extension (#18559, #16324, #18461) #18559, #16324, #18461
main 073e5c05f7 ci(duplication-guard): mirror the draft gate on lower-pins (#18559, #16324, #18461) #18559, #16324, #18461
main 4c2506c41d ci(duplication-guard): scope the tooling trees and two cross-tree sets, lower pins after merge (#18559, #16324, #18461) #18559, #16324, #18461
main 51b441e75c ci(dup): the SLM pin is the final-head measurement, 1964 (#18819) #18819
main ce02fb7c0d ci(dup): lower both jscpd pins to the #18819 measurement — SLM 2617 -> 1959, main 11231 -> 11197 (#18819) #18819
main 5ae92c9f48 ci(duplication-guard): lower both pins to the counts main measures — 11707 -> 11231 and 2831 -> 2617 (#16324) #16324
main 3ffda6346f refactor(slm-agent): the role deploys the agent from its one source tree; mirror, drift check and guard exclusion retired (#18548, #16100) #18548, #16100
this branch bc7f7c8d56 test(ci): the duplication-guard explain tests no longer read the real /tmp logs (#17377) #17377
this branch 68d7a6398c chore(ci): the duplication guard scans scripts/, tools/ and pipeline-scripts/ (#17377) #17377
this branch 85e3616038 chore(ci): pin the duplication guard at its measured figures, 11707 -> 11604 and 2831 -> 2830 (#17377) #17377

repo_tests/duplication_guard_names_the_failing_scope_test.py

side commit subject issue refs
main 00b80975d0 fix(ci): the three 18559 failure reports take overridable log paths and are tested (#18559) #18559
main 66583b7d2e ci(duplication-guard): pins move to a data file, PAT-only bot PR, trigger coverage per extension (#18559, #16324, #18461) #18559, #16324, #18461
main 4c2506c41d ci(duplication-guard): scope the tooling trees and two cross-tree sets, lower pins after merge (#18559, #16324, #18461) #18559, #16324, #18461
this branch bc7f7c8d56 test(ci): the duplication-guard explain tests no longer read the real /tmp logs (#17377) #17377
this branch 68d7a6398c chore(ci): the duplication guard scans scripts/, tools/ and pipeline-scripts/ (#17377) #17377

repo_tests/python_file_size_ratchet_test.py

side commit subject issue refs
main 0f1f7cc6e5 fix(test): gate the size ratchets against the merge base, not a shared ceiling table (#19673) #19673
main 82e2fad6f9 perf(ci): the last guards parse through the shared parse cache (#20814) #20814
main 9554e1b5d5 docs(ratchet): review -- the ratchet test docstring and the release-flip design doc no longer present the retired RATCHET_BASELINE mirror as live (#19544) #19544
main ad4e03163c dedup(ratchet): one ceiling table per size gate, checked against the base commit; a guard bars a second one (#19544) #19544
main 404c92d204 fix(ratchets): a raise its spanning run missed stays red -- every entry is also held to the last green main (AUTOBOT_RATCHET_ANCHOR); merge groups and pushes use their real base; a moved table reads its old path (#19283) #19283
main 361f419f52 test(ratchets): no hand-summed totals -- each entry is ratcheted against the base commit's own table (#19283) #19283
this branch b9a867b027 test(gates): the python ratchet tests inject through the engine, not module patches (#17377) #17377

scripts/check_frontend_file_size.py

side commit subject issue refs
main 336cd2dcfd fix(test): share one size-checker command line to clear the duplication guard (#19673) #19673
main 4a85f9aecf fix(test): answer review on the base-gated size ratchets; state the base and drop the train-repin claim (#19673) #19673
main 0f1f7cc6e5 fix(test): gate the size ratchets against the merge base, not a shared ceiling table (#19673) #19673
main ad4e03163c dedup(ratchet): one ceiling table per size gate, checked against the base commit; a guard bars a second one (#19544) #19544
main c7d1ebc4cd refactor(tooling): tracked_*_files reads EXCLUDED_PREFIXES at call time, not bound at import (#18954) #18954
main 58bf9ee7b8 refactor(tooling): one flatten, ReportError, iter_ansible_files and tracked-file binding (#18954) #18954
main 57c9349393 refactor(tooling): one file-size guard core for the python, shell and frontend gates (#18954) #18954
this branch 720457911e refactor(gates): one ratchet engine, all three size gates as configuration (#17377) #17377

scripts/check_python_file_size.py

side commit subject issue refs
main 4a85f9aecf fix(test): answer review on the base-gated size ratchets; state the base and drop the train-repin claim (#19673) #19673
main 0f1f7cc6e5 fix(test): gate the size ratchets against the merge base, not a shared ceiling table (#19673) #19673
main ad4e03163c dedup(ratchet): one ceiling table per size gate, checked against the base commit; a guard bars a second one (#19544) #19544
main c7d1ebc4cd refactor(tooling): tracked_*_files reads EXCLUDED_PREFIXES at call time, not bound at import (#18954) #18954
main 58bf9ee7b8 refactor(tooling): one flatten, ReportError, iter_ansible_files and tracked-file binding (#18954) #18954
main 57c9349393 refactor(tooling): one file-size guard core for the python, shell and frontend gates (#18954) #18954
this branch 720457911e refactor(gates): one ratchet engine, all three size gates as configuration (#17377) #17377

scripts/check_shell_file_size.py

side commit subject issue refs
main 336cd2dcfd fix(test): share one size-checker command line to clear the duplication guard (#19673) #19673
main 4a85f9aecf fix(test): answer review on the base-gated size ratchets; state the base and drop the train-repin claim (#19673) #19673
main 0f1f7cc6e5 fix(test): gate the size ratchets against the merge base, not a shared ceiling table (#19673) #19673
main 6507821100 fix(install): new installs generate the encryption key once, and every env render keeps it (#19864) #19864
main a74de0c4ff Merge remote-tracking branch 'origin/main' into issue-19544-one-ceiling-table none
main cc5fb53ba9 Merge #19365 @ 15441fd into the merge train #19365
main 2e3a41a9c8 Merge remote-tracking branch 'origin/main' into issue-19544-one-ceiling-table none
main ad4e03163c dedup(ratchet): one ceiling table per size gate, checked against the base commit; a guard bars a second one (#19544) #19544
main 6ad97ff80e fix(ansible): deploy.sh, the ansible README, two role templates and the deployment docs stop naming playbooks that do not exist (#19239) #19239
main 00d788b370 Merge remote-tracking branch 'origin/main' into issue-19232-redis-one-source none
main 57b33c0824 fix(redis): review round -- guard-scope read, one override contract, no Redis URL outside the resolver (#19232) #19232
main 7c2acc66a6 refactor(preflight): the fleet-IP derivation moves to scripts/lib/fleet-ip-rule.sh with its own tests, so pr-preflight.sh meets its ceiling by splitting (now 815), not by trimming its comments (#19233) #19233
main c69ae198a5 fix(install): the password vars file lives in a private run dir removed on any exit; the HTTPS wait needs a 2xx (#19236, #19234) #19236, #19234
main 90284442d5 fix(install): pinned defaults follow their sources, the IP cache is root-only and validated, the interface choice reads /dev/tty (#19239, #17929) #19239, #17929
main 36c83435a6 fix(install): a failed health, HTTPS, login or registration step stops the install, names the step and writes no marker (#19234) #19234
main 6 more commit(s) not listed
this branch 720457911e refactor(gates): one ratchet engine, all three size gates as configuration (#17377) #17377

@github-actions github-actions Bot added the sync-conflict Set by the branch sync (#19548) label Nov 18, 2026
@mrveiss

mrveiss commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Needs a decision before this can merge; the merge into current main was not forced.

Clash. This branch adds tools/lint/file_size_engine.py ("one ratchet engine") and rewrites the three scripts/check_*_file_size.py gates onto it (#17377). Main has since landed its own single core for the same duplication, tools/lint/_file_size_guard.py (#18954), and then changed the ratchet semantics (#19544, #19673): a file merely under its ceiling now passes and the tight gate is the merge base in the ratchet tests. The branch engine encodes the older rule (under the ceiling fails, lower the ceiling), so the six conflicting files (the three gates, repo_tests/python_file_size_ratchet_test.py, repo_tests/duplication_guard_names_the_failing_scope_test.py, .github/workflows/duplication-guard.yml) cannot be resolved by main-wins without leaving file_size_engine.py and one_file_size_engine_17377_test.py unwired, nor by keeping the branch without reverting #19673.

Options

  1. Drop the engine and its test; main's _file_size_guard.py already is the one core. Keep only the independent parts (duplication-guard scope widening to scripts/, tools/, pipeline-scripts/, and the /tmp-log-free explain tests), re-measuring the jscpd pins on current main.
  2. Make _file_size_guard.py the engine of record and port what the branch's GateConfig/injection tests add onto it, under main's ci(guards): shared guard-state files cause most PR conflicts (226 PR pairs) — nothing regenerable is committed #19673 semantics.
  3. Keep the branch engine and revert the ci(guards): shared guard-state files cause most PR conflicts (226 PR pairs) — nothing regenerable is committed #19673 semantics (not recommended: it reopens the shared ceiling-table repin problem ci(guards): shared guard-state files cause most PR conflicts (226 PR pairs) — nothing regenerable is committed #19673 closed).

Recommendation: option 1. The branch is left untouched at its previous head.

@mrveiss mrveiss added the needs-decision Blocked on an owner decision; options and a recommendation are on the issue label Nov 18, 2026
@mrveiss mrveiss changed the title test(ci): the duplication-guard explain tests no longer read the real /tmp logs (#17377) refactor(gates): one ratchet engine for the three file-size gates, duplication guard scans scripts/ and tools/ (#17377) Nov 18, 2026
@mrveiss

mrveiss commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Decision (owner, 2026-11-18): drop this branch's ratchet engine — main's shared core tools/lint/_file_size_guard.py (#18954) and its under-the-ceiling-passes rule (#19544, #19673) stay. Keep only the duplication-guard widening to scripts/ and tools/ and the /tmp-free explain tests, with the jscpd pins re-measured on current main. Rework follows in this PR.

@mrveiss mrveiss removed the needs-decision Blocked on an owner decision; options and a recommendation are on the issue label Nov 18, 2026
@mrveiss mrveiss changed the title refactor(gates): one ratchet engine for the three file-size gates, duplication guard scans scripts/ and tools/ (#17377) test(ci): the duplication-guard explain tests no longer read the real /tmp logs (#17377) Nov 18, 2026
@mrveiss

mrveiss commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Scope reduced to the explain-test log isolation only. The shared size-gate engine, the scripts/tools widening and the scope-stated-once feature were superseded by main: the engine by #18954, the pins and re-pin tooling by #19544/#19673, the tooling gate by #18461 and the cross-tree scopes by #18559 (pins live in .github/duplication-pins.json). Main wins on the three size-gate scripts, python_file_size_ratchet_test.py, duplication-guard.yml and the pins. What lands here: _run_explain points MAIN_LOG, SLM_LOG, TOOLING_LOG, CROSS_GUI_LOG and CROSS_BACKEND_LOG at a scratch directory, plus a test proving a stray /tmp/main-dup.log cannot change the verdict.

@github-actions

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@github-actions

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

@github-actions github-actions Bot removed the sync-conflict Set by the branch sync (#19548) label Nov 19, 2026
@mrveiss
mrveiss merged commit 8ef549f into main Nov 19, 2026
55 checks passed
@mrveiss
mrveiss deleted the issue-17377-one-engine branch November 19, 2026 03:11
@mrveiss mrveiss removed the land-next Landing set: CI capacity goes to these PRs first (owner direction 2026-09-18, #15397) label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase:M4.8 Shrink the symbol-fork baseline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant