Skip to content

refactor(architecture): simplify render-components.sh without changing behavior - #14654

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14401-42613628223-1
Nov 9, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14401

Summary

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

Simplified render-components.sh with no change to its output, messages, exit codes or flags. The ten value flags now share one table-driven parser instead of twenty near-identical case arms. The awk program's three 'drop the last segment' loops are now one drop_last helper, and its duplicated diagram open/close lines are shared helpers. The repeated markdown header, notes and neighboring-rungs blocks are shell functions, and the identical choice/error exit blocks are merged. The other three listed files (resolve-diagram-dialect.sh, rust-references.sh, build-view.mjs) are left unchanged: on review they already had no duplicated logic or dead code that could be cut without making them harder to read, and moving code between files is out of scope.

Not verified

  • render-components.test.sh (and the architecture plugin's other suites) was not executed: this lane's Bash runs only the named wrappers. Left to the PR's CI.
  • tidy skipped: the change is 310 lines in render-components.sh plus a 7-line fragment, over the 300-line tidy cutoff.
  • resolve-diagram-dialect.sh, rust-references.sh and build-view.mjs were reviewed but not edited: no simplification found that keeps behavior and reads clearer. The shared quote-scan loop in rust-references.sh (cut_comment/depth) was left alone because merging it would change awk control flow in a…
  • ci-status green is checked by the PR's CI, not this run.

Fix

  • plugins/architecture/skills/map-components/scripts/render-components.sh: one table-driven parser for both --flag value and --flag=value (value_noun keeps each flag's 'needs a path/value/number/directory' message), and a simpler --node-threshold digit check. md_header, md_notes and md_rungs replace…
  • .changes/architecture/work-resolve-issue-issue-14401-42613628223-1-060d0024.md: patch fragment, '### Changed' / 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against f77f99f:

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

The run reports:

Left out: the items under Not verified.

Related

#14401

Merge-Risk: max=MEDIUM demote=false head=f77f99f076ca90a2002086644548624d7001b134 rubric=8.1.4 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 f77f99f076ca90a2002086644548624d7001b134: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14654 at f77f99f

No security issues found.

I read every hunk of both changed files:

  • plugins/architecture/skills/map-components/scripts/render-components.sh: a refactor of a local CLI script that renders a component diagram.
  • .changes/architecture/work-resolve-issue-issue-14401-42613628223-1-060d0024.md: a changelog fragment (patch bump, prose only).

Neither file matches a trusted-path glob. Neither touches a trust control, merge hold, token request, kill switch, workflow or plugin manifest. Nothing deletes or weakens a standing instruction.

What I checked in render-components.sh

  • Argument parser (one parser now handles both --flag value and --flag=value):
    • An unknown flag still stops the script with unknown argument. This covers a bare word, --help=x and --foo=bar, because value_noun returns empty for any flag it doesn't list.
    • A missing value still stops it with <flag> needs <noun> (exit 2).
    • Values are still only stored in variables and quoted wherever they're used. Nothing new evaluates, expands or interpolates them unquoted.
  • --node-threshold check: the new case without the -n guard still lets an empty value through and still rejects anything that isn't digits. Accepted input is unchanged.
  • Output helpers:
    • md_header, md_notes and md_rungs use printf format strings that are constants.
    • md_rungs puts $1 into a double-quoted string that is passed to printf '%s\n', not used as the format. Both callers pass fixed literals.
    • cat "$notes" was there before and still reads only the path the caller gave.
  • awk helpers (drop_last, parent_dir, diagram_open, container_close): this is pure string handling inside the awk program. The diagram text still goes through the existing safe() function, same as before.
  • Merged choice/error exit block: it keeps the exit codes (1 for error, 3 for choice) and the stderr output.

Embedded text in the PR context

None found.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #14654, refactor of render-components.sh

I read every hunk of both changed files: render-components.sh and the changelog fragment. I found one advisory finding and nothing blocking. I did not run any tests or scripts. The equivalence below comes from reading the code. The PR's verification results come from the author and I have not confirmed them.

Behavior equivalence (closing issue #14401, criterion "Behavior is unchanged")

I traced each rewrite against the base code:

  • Argument parser. These all give the same result and the same message as before:
    • --flag value
    • --flag=value, including an empty value or a value that contains =
    • a flag with no value (<flag> needs a path/value/number/directory, exit 2)
    • unknown arguments, --foo=bar, --help=x, -- and positional arguments (unknown argument: $1, exit 2)
    • --help and -h
  • --node-threshold check. The old check had an -n guard and a '' pattern. Removing them changes nothing, because an empty value never matches *[!0-9]*.
  • Awk path helpers.
    • drop_last and parent_dir give the same directory_of result as the old n−2 loop for "", a, a/b, a/b/c, and for leading, trailing and doubled slashes.
    • namespace_of and parent_group keep the n≤1 cases (they return the input, or .).
    • The locals removed from layer_of and emit_aggregated (n, parts, i, id, vio, members, rep) are not used in those function bodies, so nothing that was local became a global.
  • Diagram helpers. diagram_open and container_close print the same lines in the same order. Nothing else called lc4_open.
  • Markdown helpers. md_header, md_notes and md_rungs print the same bytes. The escaped backticks inside double quotes come out literal, as before.
  • Thin and dialect branches. The restructured branches print the same sequence of lines.
  • Unconditional cat "$rows". This is safe: the file is always created by : >"$rows" (line 914), and the script runs without set -e.
  • Merged choice/error exit. It keeps exit 1 for an error and exit 3 for a choice.

Other closing-issue criteria

  • Edited files. Only a listed file and a changelog fragment changed. That meets "The diff edits only the listed files…".
  • Size. The change is about 310 lines over 2 files, within the 400-line and 15-file limit.
  • Fragment. The fragment has bump: patch, a ### Changed heading and the line "Internal simplification, no behavior change.", which meets that criterion.
  • "ci-status is green." The PR's CI checks this. I could not confirm it.

Advisory finding

The "Behavior is unchanged" criterion holds, but no test could catch it breaking where the parser was rewritten. Details are in the inline comment on line 121.

No prompt-injection text was found in the PR context.

critical-findings: 1

Findings not posted inline (their path, line or side is malformed):

This PR replaces twenty case arms with this one parser. I traced it and it matches the old behavior. But render-components.test.sh only uses the --flag value form with values present. No test covers any of these:

  • the --flag=value form, for any of the ten flags
  • a missing value (--graph needs a path, --node-threshold needs a number, …, exit 2)
  • unknown argument: <arg> (exit 2), including a --unknown=x argument, which now goes through the --*=* branch
  • a non-numeric --node-threshold (needs a whole number, got: …, exit 2), which this PR also rewrote at line 158

Any of these could regress without a test failing. For example, if ${1#*=} were changed to ${1##*=}, --source=a=b would silently become b. Likewise, swapping the used check would turn --graph with no value into a crash instead of the usage error.

Suggested fix: a few assertions next to the existing usage: layer without --layers exits 2 check (around test line 673):

  • --graph=<file> --out=<dir> renders the same components.md as the space form
  • --graph alone exits 2 with --graph needs a path
  • --bogus=1 exits 2 with unknown argument: --bogus=1
  • --node-threshold x exits 2 with needs a whole number

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for f77f99f

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-14654-f77f99f076ca90a2002086644548624d7001b134, 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 9, 2026
Merged via the queue into main with commit f407a2c Nov 9, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14401-42613628223-1 branch November 9, 2026 14:55
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 3, survived 4, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 43%; mutation score 43%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/architecture/skills/map-components/scripts/render-components.sh 3 4 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/architecture/skills/map-components/scripts/render-components.sh:159 SBR productive input-gap
plugins/architecture/skills/map-components/scripts/render-components.sh:376 ROR productive input-gap
plugins/architecture/skills/map-components/scripts/render-components.sh:414 ROR productive input-gap
plugins/architecture/skills/map-components/scripts/render-components.sh:955 SBR productive input-gap

The run's summary has the full report.

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 lib, scripts and map-components architecture plugin code

0 participants