Skip to content

refactor(harness-ops): simplify inventory.py part 2 of 4 - #15127

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14559-42842111577-1
Nov 10, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14559-42842111577-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14559

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Simplified the functions that start in range 2 of 4 of plugins/harness-ops/skills/inventory/scripts/inventory.py. The file had 6918 lines when this part started, so the range is lines 1730-3459: functions _chunk_starts through _is_loop_registration. Each edit keeps the code's behavior. A new private _name_re(ident) helper replaces four copies of the same whole-name regex. _nearest_binding now reuses _binding_pattern, which already held the exact same pattern, and the performance note moved with it. _function_body loses a repeated _chunk_span call and a duplicated _declaration call. The other edits drop repeated .strip() calls and index arithmetic in _chunk_imports and _export_index, and collapse a few branches in _spread_array, _written_elsewhere, _resolve_chain and command_invocability. Nothing else changed: no names, flags, outputs or files.

Not verified

  • Python test suite (test_inventory.py) and ruff/mypy not run: this lane can run no interpreter. Left to the PR's CI.
  • ai-slop:audit fix pass: the detector script is not among the wrappers this lane may run, so only the rubric read ran on the 2-line fragment, whose wording the issue fixes
  • An existing mypy issue the review noted: _resolve_chain annotates chain as list[tuple[str, str]] but reads chain[1][2]. It is out of scope because fixing it changes a signature annotation, and it predates this change.
  • ci-status green: a PR CI check, left to the PR's CI

Fix

  • plugins/harness-ops/skills/inventory/scripts/inventory.py: range-2 simplifications (43 added, 63 removed lines): new private _name_re helper used by _redeclared_later, _unset_between, _written_elsewhere and _argument_object; _nearest_binding reuses _binding_pattern; _function_body drops its…
  • .changes/harness-ops/work-resolve-issue-issue-14559-42842111577-1-a3c58405.md: patch fragment created by new-changelog-fragment, body '### Changed' plus 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 4bf948f:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • check-changelog-fragments: all 10 fragments valid (run before and after tidy)
  • check-changed-skills: inventory PASS, 0 errors, 2 existing size warnings on SKILL.md, which this change does not touch
  • check-affected: 13 passed, 6 skipped over 2 changed files
  • fresh-context review subagent (blind to rationale) checked each hunk for behavior equivalence: all 13 hunks equivalent, no new mypy error
  • grep: test_inventory.py patches none of the changed functions; it calls _nearest_binding directly, whose signature is unchanged
  • tidy-diff (code-tidying): all 25 rows taken; simplify, comment and residue passes found nothing more to change; write-for-humans and an ai-slop rubric read left the mandated fragment text unchanged
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42842111577

Left out: the items under Not verified.

Related

#14559

Merge-Risk: max=MEDIUM demote=false head=4bf948f54852e7df7047200a073058c54b561ce0 rubric=8.3.5 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 4bf948f54852e7df7047200a073058c54b561ce0: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15127, head 4bf948f

I found no security issues.

What I read: both changed files, every hunk.

  • .changes/harness-ops/…a3c58405.md: a new patch changelog fragment. It is prose only and controls nothing.
  • plugins/harness-ops/skills/inventory/scripts/inventory.py: a refactor of the parser that reads JavaScript source for the inventory skill. It adds a _name_re(ident) helper. Every pattern it builds runs the identifier through re.escape, as the four copies it replaces did, so this adds no way to inject a pattern. _nearest_binding now calls the existing _binding_pattern, which builds the same escaped pattern. The other edits use the walrus operator in place of repeated .strip() calls, swap index arithmetic for zip, and fold a few branches together in _function_body, _spread_array, _written_elsewhere, _resolve_chain and command_invocability. None of them adds a subprocess call, a filesystem path, a network call, or any handling of tokens or secrets.

Trusted paths and trust controls: neither changed file matches a trusted-path glob. The diff does not touch the trusted-actor list, the token broker, the kill switch, any merge hold, any plugin manifest or userConfig key, or any standing instruction such as CLAUDE.md, a skill body or a hook. That leaves no manifest lines to report and no instruction-surface deletions to check.

PR context: I found no embedded instructions aimed at the review lane.

Prior findings: this is the lane's first review of this pull request, so the review was not limited to blocking findings.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 4bf948f54852e7df7047200a073058c54b561ce0: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15127, simplify inventory.py (part 2 of 4)

No findings. I read both changed files in full: the changelog fragment and plugins/harness-ops/skills/inventory/scripts/inventory.py. I checked every hunk against the unchanged code around it to confirm the behavior is the same.

How each hunk checks out

  • _chunk_imports / _export_index: part.strip() runs before partition(" as "), so the alias half can never be only whitespace. That makes local.strip() or exported give the same key as the old (local or exported).strip(). The new zip(starts, starts[1:] + (len(src),)) works because _chunk_starts returns tuple[int, ...] (L1745). Adding a tuple to a tuple is valid, and the pairs match the old index arithmetic.
  • _name_re: it builds exactly the regex that the four call sites used to build inline.
  • _nearest_binding: it now calls _binding_pattern, which compiles the same pattern character for character.
  • _function_body: the second _chunk_span call it drops returned the same (lo, hi). The old _declaration(...) or pattern.search(...) behaves the same as if found is None and single_module, because a re.Match is always truthy. The found: re.Match[str] | None = top[0] annotation narrows on assignment, so found.end() after the if/else should not trip mypy.
  • _resolve_chain: chain is not reassigned between where single is computed and the last place it is used (deferred=deferred or single).
  • _written_elsewhere, _spread_array, command_invocability: control flow is unchanged. Only branches were merged and an intermediate variable was named.

Closing issue #14559, acceptance criteria

  • Behavior unchanged: met by reading the hunks above. As the issue's out-of-scope list allows, no new test covers it. The author says the Python suite, ruff and mypy were not run and leaves them to CI. I could not run them either.
  • Only the listed file and a fragment are edited: met.
  • Under 400 changed lines: met (about 43 added, 63 removed).
  • Fragment bump: patch, body ### Changed / "Internal simplification, no behavior change.": met.
  • Only functions that start in range 2 (lines 1730–3459) are changed: met. The changed functions run from _chunk_imports (L1771) to _argument_object (~L3300).
  • ci-status green: left to CI; I did not verify it.

Not covered: I found no plugin manifest changes, paved-path citations or embedded directives in the PR context. The prior-findings file lists no earlier reviews, so this was a full review, not blocking-only. The only spend is this review run's usage; nothing in the change can start a charge.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 4bf948f54852e7df7047200a073058c54b561ce0, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 4bf948f

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-15127-4bf948f54852e7df7047200a073058c54b561ce0, expires on 2026-12-10.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 6acd0c7 Nov 10, 2026
64 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14559-42842111577-1 branch November 10, 2026 16:30
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 6acd0c7fa57395f936dae571eef06e3ea1528ec5; later checks count it verified from this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify the inventory.py harness-ops plugin code (part 2 of 4)

0 participants