Skip to content

refactor(util): read the helper's annotations in #1672's KTLO scan, then use it for the rest (#2047) - #2054

Merged
JarryShaw merged 1 commit into
mainfrom
refactor/2047-actions-helper-2
Oct 22, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
refactor/2047-actions-helper-2

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • refactor — restructures code without changing behaviour

Description of your pull request and other information

The second PR for #2047 (owner's ruling: option (a)).

  • ci: a failed KTLO leg turns main and pull requests red; report it as a warning and exit 0 #1672's KTLO guard reads helper annotations. The guard is commands() in test_ktlo_legs_stay_green_1672.py. It now also parses each util/ script a step runs for _actions.annotate/annotation calls: by attribute, by imported name or alias, with the level positional or level=. A literal level counts as itself, and a name maps to ${NAME}. An unreadable level becomes {?}, which fails the guard rather than passing.
    • Proof: seeding _actions.annotate('error', ...) into util/leg_summary.py fails the guard on every KTLO job (10 failures). The old guard missed it, and seeding 'warning' passes.
    • A gap closed: batch 1's pip_install.py already used the helper and was invisible to the old regex. It now reads as ${ANNOTATION_LEVEL}, which the guard allows.
  • Moved onto the helper: the annotations batch 1 kept literal in apt_packages.py, leg_summary.py and coverage_report.py. They use escape=False where a script escapes its own way. main's copies and this PR's give byte-identical stdout, stderr, exit code, outputs and summary: 144/144 cases under /usr/bin/python3.7 and 144/144 under 3.14, across four locale settings.
  • Tests: the guard, helper and apt tests, plus every test of the migrated scripts, all pass (90 passed for the first three). No existing assertion is weakened; the guard only gains reads.

…hen use it for the rest (#2047)

- tests/project/test_ktlo_legs_stay_green_1672.py: commands() now reads an
  annotation written through util/_actions.py at its level -- annotate() or
  annotation(), as an attribute or a name imported from _actions, by first
  argument or level= -- and a level it cannot read counts as one no KTLO step
  may write. pip_install's helper annotation, unseen until now, reads as
  ${ANNOTATION_LEVEL}. New checks seed copies of util/leg_summary.py.
- apt_packages, leg_summary, coverage_report: the annotations batch 1 left
  literal go through the helper, unescaped as before; output is unchanged.
@JarryShaw JarryShaw added ci Pull requests that change CI or workflow configuration (ci: subject prefix) refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 22, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at b23faba24 (Sonnet cross-review).

  • Guard: the reviewer seeded 19 forms into the KTLO summary script. Aliases, import _actions as A, print(_actions.annotation(...)) and import_module(...) calls are all caught. A level held in a constant, *args, **kw or a conditional reads as unreadable, so the guard fails safe. Nothing on main is flagged by mistake.
  • Byte-identical: 143 adversarial cases under 3.7 and 3.14, 286 runs, 0 diffs.
  • pip_install.py: confirmed invisible to the old guard. It now reads as ${ANNOTATION_LEVEL}, and every KTLO or experimental job that runs it is in LEVELLED.
  • Assertions: the test diff only adds; nothing is weakened.

Known limits, not blocking: getattr(_actions, 'annotate')(...), binding the function to a variable, functools.partial, and from _actions import * still get past the guard. Each takes deliberate evasion, and no script uses any of them. The same is true on main of sys.stdout.write('::error::').

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 22, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 22, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Ordering check on b23faba24: the project leg (util/run_unittest_leg.py project) ran 1912 tests, OK (71 skipped). CI: 66 checks green, 0 failing. KTLO 3.8, 3.9 and 3.10 legs: 0 failing tests. Ready to merge.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 91.54% (unit tier, Python 3.15, b23faba24, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 19599 881 2618 867 92.11%
pcapkit/corekit 2567 71 816 37 96.57%
pcapkit/dumpkit 282 3 102 3 98.44%
pcapkit/foundation 2930 23 1022 25 98.79%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 17436 219 4582 185 98.15%
pcapkit/toolkit 872 36 298 10 95.21%
pcapkit/utilities 529 7 160 5 98.26%
pcapkit/vendor 4431 1995 1018 167 51.73%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit bd58ef2 into main Oct 22, 2026
68 checks passed
@JarryShaw
JarryShaw deleted the refactor/2047-actions-helper-2 branch October 22, 2026 22:52
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 22, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 22, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Pull requests that change CI or workflow configuration (ci: subject prefix) refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant