Skip to content

refactor(knowledge): simplify map-corpus discovery, extraction and gate scripts - #14867

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14602

Summary

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

Simplified four of the six listed map-corpus scripts with no behavior change: same output, messages, exit codes, flags and module-level names. check_linkmap.py now uses one is_nonempty_string_list helper for its two non-empty-string-list checks and builds rungs_by_url and tally directly. parse_discovery.py's normalize_url uses str.rpartition for the userinfo/host split, and extract_markdown_urls handles matches in one loop. extract_nodes.py's markdown scan is a for loop instead of a hand-advanced while loop. Both gates drop a redundant except SystemExit: raise, since except Exception never catches SystemExit. repo_tree_adapters.py and lib/gate_common.py were already minimal, so they are unchanged. No code moved between files, per the issue's out-of-scope list.

Not verified

  • The map-corpus Python test suites (test_discovery.py, test_extract_nodes.py, test_check_inventory.py) were not run: this lane allows no interpreter. Left to the PR's CI.
  • ci-status green is a PR CI check; left to the PR's CI.
  • cant-fail-scan was not run: its wrapper takes no base ref and it scans test files, and this change touches none. It runs in CI.
  • ai-slop's detect.sh was not run on the changelog fragment (the lane runs only its named wrappers). I read the one mandated line against the rubric instead, and no findings file was written.
  • Untracked runner files at the checkout root (.bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) predate this run and are not part of this change.

Fix

  • plugins/knowledge/skills/map-corpus/discovery/check_linkmap.py: added is_nonempty_string_list for the seeds and urls checks; rungs_by_url built by a dict comprehension; tally via dict.fromkeys; reused label in one failure message (same text); removed redundant except SystemExit: raise.
  • plugins/knowledge/skills/map-corpus/discovery/parse_discovery.py: normalize_url merges its two early returns and uses rpartition('') for the host-lowercasing branch; extract_markdown_urls processes matches in one loop instead of building an intermediate list.
  • plugins/knowledge/skills/map-corpus/extraction/extract_nodes.py: markdown_boundaries scans with for-range instead of a while loop with an i += 1 on every branch; fewer temporaries in the ATX and setext branches; html_boundaries uses len(m.group()) and names the unclosed-comment offset comment_start.
  • plugins/knowledge/skills/map-corpus/verification/check_inventory.py: verdict_counts via dict.fromkeys; removed redundant except SystemExit: raise.
  • .changes/knowledge/work-resolve-issue-issue-14602-42704462371-1-009b4631.md: new knowledge patch fragment, created with new-changelog-fragment knowledge patch: '### Changed' / 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 1ae8ec7:

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

The run reports:

  • check-changelog-fragments: all 19 fragments valid (run before and after tidy).
  • check-changed-skills: map-corpus PASS, 0 errors, 1 warning (the SKILL.md body length warning, which predates this change; SKILL.md was not touched).
  • check-affected: 13 passed, 6 skipped over 5 changed files.
  • Fresh-context subagent review of the full diff against HEAD: no behavior differences found. It checked rpartition vs rsplit, the dict comprehension with duplicate seeds, the while-to-for loop index, the SystemExit removal, the order of exceptions in extract_markdown_urls, and dict.fromkeys with…
  • code-tidying:tidy-diff over the 20 changed hunks: no further edits; the one comment in the listed lines is load-bearing and kept; the fragment's mandated line has no AI-writing tells.
  • Diff size: 5 files, 47 added / 69 removed lines in code plus a 7-line fragment, within the issue's 400-line / 15-file limit.
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42704462371

Left out: the items under Not verified.

Related

#14602

Merge-Risk: max=LOW demote=false head=1ae8ec7bc321c31cc203bc8b816949dab8dd4e52 rubric=8.2.0 rater=claude-opus-5-5 checker=claude-opus-5-5

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

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 1ae8ec7bc321c31cc203bc8b816949dab8dd4e52: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14867

I found no security issues in this pull request.

Scope. I read every hunk in all 5 changed files: the changelog fragment and four map-corpus scripts (check_linkmap.py, parse_discovery.py, extract_nodes.py, check_inventory.py). None of them match a trusted-path glob. The diff doesn't touch any plugin manifest, workflow, trust control, merge hold or standing instruction.

What I checked:

  • normalize_url (parse_discovery.py). The base code split userinfo from host with rsplit("@", 1). The new code uses rpartition("@"). Both split at the last @ and lowercase only the host, and with no @ the whole netloc is lowercased, as before. Merging the scheme check and the netloc check into one early return still rejects any URL that isn't http/https or has no host. URL filtering isn't loosened.
  • Removed except SystemExit: raise (both gates). SystemExit derives from BaseException, not Exception, so the remaining except Exception handler can't catch it. Exit codes, including the documented fail exits, behave as before.
  • markdown_boundaries loop (extract_nodes.py). The base while loop added 1 to i on every path, including the setext branch and the fall-through. The new for i in range(...) loop visits each line the same way. The consumed and in_fence handling is unchanged.
  • The other edits (is_nonempty_string_list, dict.fromkeys, the dict comprehension for rungs_by_url, the unclosed-comment masking) are equivalent rewrites of local validation and parsing. No new input reaches a shell, a path, a credential or a network sink.

PR context. The description holds no embedded instructions aimed at the review lane.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed 1ae8ec7bc321c31cc203bc8b816949dab8dd4e52: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

This PR simplifies four map-corpus scripts and adds a changelog fragment. I read every hunk in all 5 changed files and compared each rewrite with the code it replaces. None of them changes behavior.

What I checked

  • check_linkmap.py
    • The new is_nonempty_string_list helper behaves the same as the two inline checks it replaces.
    • Building rungs_by_url with a dict comprehension gives the same keys, the same insertion order and a separate {"seed"} set per seed, even when seeds repeat.
    • dict.fromkeys(CLASSIFICATIONS, 0) gives the same result as the old dict comprehension.
    • The reused label still reads row[{index}] at that point, because it is only reassigned on the line after.
    • Dropping except SystemExit: raise is safe. except Exception never catches SystemExit, so fail() exit codes and sys.exit(main()) behave as before.
  • parse_discovery.py
    • rpartition("@") splits the netloc the same way as the old rsplit("@", 1) / else pair. With no @, both lowercase the whole netloc.
    • extract_markdown_urls still collects URLs in the same order: all markdown links first, then autolinks, then bare URLs.
  • extract_nodes.py
    • The old while loop added 1 to i on every branch and never jumped further, so the for range(idx, len(lines)) loop visits the same lines.
    • In the setext branch, the old continue and the fall-through both led only to i += 1.
    • Nothing after the loop reads i.
    • The bytes strip() truthiness test matches the old != b"" comparison.
    • len(m.group()) equals m.end() - m.start().
  • check_inventory.py: the same dict.fromkeys and SystemExit changes as in check_linkmap.py, and equally safe.

Closing issue #14602, acceptance criteria

  • Behavior unchanged: met, by my reading of the code above. The existing map-corpus test suites cover these paths. The author did not run them and leaves them to CI. I could not run them either, so this is unconfirmed.
  • Only listed files and fragments edited: met. repo_tree_adapters.py and lib/gate_common.py are listed in the issue but left unchanged; the PR body says they were already minimal.
  • Size limit: met (5 files, about 116 changed lines).
  • ci-status green: left to CI.
  • Changelog fragment: met. It is a knowledge patch fragment with ### Changed and the required line.

The author's verification claims (the fragment and skill checks, and the subagent review) are their own; I have not confirmed them. No plugin manifests changed. No trusted paths are touched.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 1ae8ec7

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-14867-1ae8ec7bc321c31cc203bc8b816949dab8dd4e52, expires on 2026-12-09.

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 2e7cbe8 Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14602-42704462371-1 branch November 10, 2026 01:01
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 map-corpus knowledge plugin code

0 participants