Skip to content

refactor(architecture): simplify map-context collect and render scripts - #15180

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14403

Summary

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

Simplified the two map-context scripts with no behavior change. collect-context.sh now has a json_field helper for building JSON objects, sorts in place with sort -u -o instead of a temp file plus mv, writes the actor loop's output with one redirect, adds ext_body to the EXIT trap, and merges nested ifs and a no-op case into single conditions. render-context.sh gets an awk swap() helper for its three sorts, sets the default person description once instead of in each dialect branch, drops a brace group that only grouped code, and puts the closing code fence in each dialect branch. I chose these edits by reading the code: every output byte, exit code, flag and message stays the same, and a fresh-context review found no difference for any realistic input.

Not verified

  • Script test suites (collect-context.test.sh, render-context.test.sh) were not run directly: this lane runs no interpreter or test runner. Left to the PR's CI.
  • ci-status green is a PR CI check, left to the PR's CI.
  • Review edge case not fixed: if mktemp fails (unwritable TMPDIR), stderr shows one redirect error for the actor loop instead of one per actor line, and no skipped-actor warnings. The record bytes are the same. This only happens on an already-broken host.
  • Tidy proposal not applied: the '[[ -n "$host" ]] || continue' guard in collect-context.sh's externals loop is unreachable, because the awk filter already requires a non-empty host. Left in because tidy-diff only proposes changes of this kind.
  • Tidy pass 5 (ai-slop:audit fix) ran the rubric read only: the deterministic detector detect.sh cannot run in this lane, whose Bash runs only named wrappers. The fragment text is fixed word for word by the issue.

Fix

  • plugins/architecture/skills/map-context/scripts/collect-context.sh: added json_field helper; the externals and actor objects are built with printf plus json_field; sort -u -o in place replaces the mktemp+mv sorts and their -s guards; ext_body is created with the other temp files and removed by the…
  • plugins/architecture/skills/map-context/scripts/render-context.sh: added awk swap() for the three selection sorts; the 'Operator-stated actor' default is set once on adesc[] beside alias assignment instead of in each dialect branch; the brace group in END is removed (re-indented); the closing ```…
  • .changes/architecture/work-resolve-issue-issue-14403-42885974382-1-7c861000.md: new patch fragment, '### Changed' with 'Internal simplification, no behavior change.'

Verification

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

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

The run reports:

  • .lane/checks/bin/check-changelog-fragments: all 4 fragments valid
  • .lane/checks/bin/check-changed-skills: map-context PASS, 0 errors (1 pre-existing body-length warning)
  • .lane/checks/bin/check-affected: first run failed shellcheck SC2209 on an unquoted mode=env; restored the quotes; re-run 13 passed, 6 skipped, 0 failed
  • fresh-context review subagent over the whole diff against HEAD: no behavior difference for realistic inputs. Checked: .env globs, sort -o on the same file, empty or comment-only or no-trailing-newline actor files, no config hits, the trap, the > vs >> redirect, awk array passing in swap()…
  • tidy-diff (code-tidying:tidy-diff) over every changed hunk: no further edits; one proposal recorded
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42885974382

Left out: the items under Not verified.

Related

#14403

Merge-Risk: max=LOW demote=false head=e8151fafa4743695fb3a977a9ecfe96e7b9d1115 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 e8151fafa4743695fb3a977a9ecfe96e7b9d1115: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15180 (no security issues found)

This pull request refactors two map-context scripts and adds a changelog fragment. I found no security issues. I read every hunk of all 3 changed files. None of them matches a trusted path, and none is a plugin manifest or an instruction surface.

What I checked

  • Secret redaction in collect-context.sh. The actor loop's output now goes to $actor_body through one redirect around the whole loop. The redaction check redact_is_secret (plugins/architecture/lib/redact-connection.sh:42-46) only sets an exit status and prints nothing to stdout. The "skipped an actor line" notice still goes to stderr (collect-context.sh:259). So no redaction output and no secret-bearing line can land in the record, and lines with connection material are still skipped before they are written.
  • JSON escaping. The new json_field helper (collect-context.sh:86-89) runs json_escape on every value before printing it. The field names it receives are fixed strings in the script. Escaping is the same as before.
  • File selection. The .env match changed from *".env" / "$base" != "${base#.env}" to *.env / .env*, which selects the same files. Dropping the [[ -n "$rel" ]] guard is safe: an empty path becomes $root/, a directory, which the -f test then skips. The checks on symlinks, file size and host format are unchanged.
  • Temp files. sort -u -o writing back to its own input file is safe, because sort reads all input before it opens the output. $ext_body is now created up front and removed by the EXIT trap, so the trap covers more than before.
  • render-context.sh. The awk swap() helper and the restructuring keep safe() on every interpolated value: actor names and descriptions, the focal system, hosts, and evidence fields. No unescaped text reaches the PlantUML or LikeC4 output.

Embedded text: none. The PR context only describes the change.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15180 (refactor(architecture): simplify map-context collect and render scripts)

No findings. I read every hunk of all 3 changed files and compared each rewrite with the base logic. Every rewrite produces the same output as before.

What I checked: collect-context.sh

  • json_field helper. It writes the same keys in the same order as before (host, kind, port, file, key, origin and name, description, origin). json_escape only sets JSON_ESC and prints nothing, so the escaping is the same.
  • Actor loop now uses one >"$actor_body" redirect. Nothing else in the loop body writes to stdout:
    • the skip warning goes to >&2;
    • redact_is_secret (plugins/architecture/lib/redact-connection.sh:42-46) runs an awk program that only uses BEGIN { exit ... }, so it prints nothing and does not read the loop's stdin.
  • sort -u -o f f in place of the -s-guarded temp file and mv. POSIX allows -o to name an input file. An empty file stays empty.
  • .env match. *.env || .env* is the same test as the old *".env" || "$base" != "${base#.env}".
  • Removed [[ -n "$rel" ]] guard. An empty entry would make abs the root directory, which -f already skips.
  • Externals loop over an empty hits file. It produces an empty ext_body, the same as the old -s guard did.
  • Temp files. ext_body is now removed by the EXIT trap, which also covers the early die "not a git repository" path.
  • Nested if merged into &&. Same result.

What I checked: render-context.sh

  • swap(). Awk passes arrays by reference and t is now a local. I found no other use of a global t.
  • adesc[] default set once up front. Only the two diagram branches read adesc, so the none dialect and the Nodes table are unchanged.
  • Closing code fence moved into each branch. It is emitted exactly when dialect != "none", as before.
  • Brace group removed. It only grouped code, so this is a re-indent.

Closing issue #14403 acceptance criteria

  • Behavior unchanged: met, by my reading of the code. The existing collect-context.test.sh and render-context.test.sh would catch a regression. I did not run them here; the author also says they did not run them and left them to CI.
  • Edits only the listed files plus a fragment: met.
  • Within 400 changed lines and 15 files: met.
  • ci-status green: left to CI; I could not confirm it from here.
  • Fragment: met. .changes/architecture/… has bump: patch, ### Changed and the required line word for word.

No plugin manifest changed, and none of the changed files matches a trusted path. The PR context contains no embedded instructions aimed at the lane.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for e8151fa

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-15180-e8151fafa4743695fb3a977a9ecfe96e7b9d1115, 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 d27a450 Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14403-42885974382-1 branch November 10, 2026 22:06
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit d27a45040225e975ab3dfa55b0130f0dd06b9cda; 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 map-context architecture plugin code

0 participants