Skip to content

refactor(architecture): share the record-layout open_array awk function through lib record-layout.sh - #15597

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-15583-43243135531-1
Nov 12, 2026
Merged

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #15583

Summary

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

plugins/architecture/lib/record-layout.sh now exposes the open_array awk function once as RECORD_OPEN_ARRAY_AWK (newline-terminated, read from a quoted heredoc like the lib's existing program so shellcheck SC2016 stays clean) and builds its own _RECORD_LAYOUT_AWK from it; record_layout_problem is unchanged. The seven layout-check scripts source the lib the same way they already locate their other lib files, delete their verbatim copy, and prefix their program with the variable: render-components, render-context and render-dependencies run awk "$RECORD_OPEN_ARRAY_AWK$LAYOUT_AWK", and collect-containers, render-containers, render-events and render-flow run awk "$RECORD_OPEN_ARRAY_AWK"'...'. Each removed body matched the lib's function byte for byte apart from indentation, and awk accepts a function definition anywhere at top level, so outputs, exit codes and layout error text are unchanged. The review raised two low findings, both declined: a missing or relocated lib would now let the layout check fail open in these scripts. landscape-record.sh and render-landscape.sh already carry that exposure with this lib, and nothing in the repo symlinks or copies the scripts.

Not verified

  • render-components.test.sh, collect-containers.test.sh, render-context.test.sh, dependency-graph.test.sh, collect-events.test.sh, collect-flow.test.sh, landscape-record.test.sh and render-landscape.test.sh were not executed here: the lane runs no test runner or interpreter. Left to the PR's CI.
  • ci-status green on the PR: left to the PR's CI.
  • tidy pass 5 (ai-slop fix on the fragment): the rubric read found no tells, but the deterministic detector (detect.sh) is not among this lane's runnable wrappers, so it did not run.
  • Untracked runner files at the checkout root (.bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) are environment artifacts, not part of this change, and were left out of the tidy measure.

Fix

  • plugins/architecture/lib/record-layout.sh: adds RECORD_OPEN_ARRAY_AWK (the open_array function, ending in a newline) and prefixes it to _RECORD_LAYOUT_AWK in place of the inline copy
  • plugins/architecture/skills/map-components/scripts/render-components.sh: sources record-layout.sh, drops its open_array copy, runs awk "$RECORD_OPEN_ARRAY_AWK$LAYOUT_AWK"
  • plugins/architecture/skills/map-containers/scripts/collect-containers.sh: sources record-layout.sh beside its other libs, drops its open_array copy, prefixes the graph layout program with RECORD_OPEN_ARRAY_AWK
  • plugins/architecture/skills/map-containers/scripts/render-containers.sh: sources record-layout.sh, drops its open_array copy, prefixes the layout program with RECORD_OPEN_ARRAY_AWK
  • plugins/architecture/skills/map-context/scripts/render-context.sh: sources record-layout.sh, drops its open_array copy, runs awk "$RECORD_OPEN_ARRAY_AWK$LAYOUT_AWK"
  • plugins/architecture/skills/map-dependencies/scripts/render-dependencies.sh: sources record-layout.sh, drops its open_array copy, runs awk "$RECORD_OPEN_ARRAY_AWK$LAYOUT_AWK"
  • plugins/architecture/skills/map-events/scripts/render-events.sh: sources record-layout.sh, drops its open_array copy, prefixes the layout program with RECORD_OPEN_ARRAY_AWK
  • plugins/architecture/skills/map-flow/scripts/render-flow.sh: sources record-layout.sh, drops its open_array copy, prefixes the layout program with RECORD_OPEN_ARRAY_AWK
  • .changes/architecture/work-resolve-issue-issue-15583-43243135531-1-a9a22d63.md: new patch fragment, ### Changed: Internal restructuring, no behavior change.

Verification

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

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

The run reports:

  • check-changelog-fragments: all 6 fragments valid
  • check-changed-skills: 6 skills checked, 0 failed (pre-existing size warnings only)
  • check-affected: first run failed shellcheck SC2016 on the single-quoted RECORD_OPEN_ARRAY_AWK; switched to a quoted heredoc plus an appended newline; re-run: 13 passed, 6 skipped, 0 failed
  • git-read diff --unified=0 HEAD: each of the seven removed open_array bodies matches record-layout.sh's function line for line apart from indentation
  • fresh-context review subagent over the eight scripts and the fragment: no correctness bugs; two low findings (missing lib fails open) declined as above
  • tidy-diff over the 15 changed hunks: no simplification, comment or residue edits needed; the fragment line keeps the issue's prescribed wording
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43243135531

Left out: the items under Not verified.

Related

#15583

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

Security review: PR #15597 (head d2aad36)

I found no security issues. I read every hunk of all 9 changed files.

What the change does. It is a refactor. The open_array awk function used to be copied into seven layout-check scripts under plugins/architecture/skills/*/scripts/. It now lives once in plugins/architecture/lib/record-layout.sh as RECORD_OPEN_ARRAY_AWK. Each script sources that lib and puts the variable in front of its own awk program. A patch changelog fragment is also added.

What I checked:

  • Where the sourced file comes from. Each script finds the lib by a fixed path relative to its own directory ($(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../../lib/record-layout.sh, or the $SCRIPT_DIR the script already uses for its other libs). That path is inside the plugin itself, so it can't be steered by user input or the environment.
  • Injection into awk. RECORD_OPEN_ARRAY_AWK is read from a quoted heredoc (<<'AWK'), so the shell expands nothing in it, and it is fixed text with nothing interpolated (
    read -r -d '' RECORD_OPEN_ARRAY_AWK <<'AWK' || true
    function open_array(key, rest) {
    if (!match($0, "\"" key "\"[[:space:]]*:[[:space:]]*\\[")) return
    rest = substr($0, RSTART + RLENGTH)
    if (rest ~ /^[[:space:]]*\]/) { seen[key] = 1; return }
    if (substr($0, 1, RSTART - 1) ~ /^[[:space:]]*$/ && rest ~ /^[[:space:]]*$/) { open = key; return }
    problem = "the " key " array does not start on a line of its own"
    }
    AWK
    RECORD_OPEN_ARRAY_AWK+=$'\n'
    ). In every script the variable is joined only to that script's own literal program, and the record file is still passed as a separate argument. No data from a record reaches the awk program text.
  • Side effects of sourcing. The lib's only top-level actions are its guard against being run directly, two variable assignments and one function definition. It changes no shell options and runs nothing at source time.
  • Trusted paths and trust controls. None of the changed files matches a listed trusted path. The diff touches no workflow, action, token request, trusted-actor list, kill switch, merge hold or plugin manifest.
  • Instruction surface. The diff deletes no standing instruction (CLAUDE.md, a skill or agent body, a hook list), so the instruction-exception register did not apply.

Not a security finding. If the lib were missing, RECORD_OPEN_ARRAY_AWK would be empty. awk would then fail to parse, and the layout check could let a record through. The PR description already mentions this. The lib ships inside the same plugin directory, so no attacker can trigger it, and it is at most a robustness question for the code-review lane.

PR context. The description contains nothing that tells the lane to pass the PR, skip a check or drop a finding.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15597, sharing open_array through lib/record-layout.sh

No findings. I read every hunk of all 9 changed files.

What I checked

  • The shared lib (plugins/architecture/lib/record-layout.sh): RECORD_OPEN_ARRAY_AWK comes from a quoted heredoc via read -r -d ''. That strips the trailing newline, and line 33 adds it back. So both kinds of use work: "$RECORD_OPEN_ARRAY_AWK$LAYOUT_AWK" and "$RECORD_OPEN_ARRAY_AWK"'...' each put a newline between the function and the rest of the program. The function's first line has no leading whitespace for IFS trimming to remove, and -r keeps the \\[ and \] escapes. _RECORD_LAYOUT_AWK is now the prefix plus the old program, so record_layout_problem behaves as before.
  • The seven scripts: each removed open_array body matches the lib's function apart from indentation. Each script sources the lib at top level before its program runs. collect-containers.sh does it beside its other $SCRIPT_DIR libs; the rest use the $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) form already used in render-landscape.sh. The lib's "executed directly" guard (BASH_SOURCE[0] == $0) is false when sourced. The lib adds only RECORD_OPEN_ARRAY_AWK, _RECORD_LAYOUT_AWK and record_layout_problem, and none of those names is already defined in the sourcing scripts. Awk accepts a function definition anywhere at top level, so moving it to the front of each program changes nothing.
  • Tests that copy or symlink the scripts: the only ln -s calls in the architecture tests link fixture files, not these scripts, so the relative lib path still resolves under test.
  • Closing issue Share the record-layout open_array awk function through lib/record-layout.sh #15583:
    • open_array now exists once, in the lib, and the seven scripts use it.
    • The diff touches only the listed files plus the requested patch fragment (### Changed, "Internal restructuring, no behavior change."), well under 400 lines and 15 files.
    • The behavior-unchanged and tests-pass criteria are covered by the existing render/collect test suites. I did not run them, and the author says they did not either; that and green ci-status are left to CI and are unverified here.
  • Known risk, left as is: the author raised and declined one point. With set -uo pipefail and no -e, a missing lib would make the layout check fail open. The awk runs inside $(...), so the unbound-variable error exits only that subshell and leaves an empty problem string, which reads as "no problem". landscape-record.sh and render-landscape.sh already have the same exposure with this lib, and no script is relocated. I agree this falls below the reporting bar.

No plugin manifest changed, so there are no manifest lines. No settled threads or prior findings applied (no earlier head was reviewed). There was no embedded text in the PR context that tried to steer the review.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for d2aad36

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-15597-d2aad369b8f7cc62ca98320b18fdf4ffaeec1f4a, expires on 2026-12-12.

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 12, 2026
Merged via the queue into main with commit 9775413 Nov 12, 2026
63 of 65 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-15583-43243135531-1 branch November 12, 2026 15:36
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 5, survived 2, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 71%; mutation score 71%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/architecture/lib/record-layout.sh 2 1 0 0 0 0
plugins/architecture/skills/map-components/scripts/render-components.sh 1 0 0 0 0 0
plugins/architecture/skills/map-containers/scripts/collect-containers.sh 0 1 0 0 0 0
plugins/architecture/skills/map-dependencies/scripts/render-dependencies.sh 1 0 0 0 0 0
plugins/architecture/skills/map-events/scripts/render-events.sh 1 0 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/architecture/lib/record-layout.sh:33 SBR unclassified none
plugins/architecture/skills/map-containers/scripts/collect-containers.sh:349 SBR productive input-gap

The run's summary has the full report.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 9775413255b312fbff1d04446130c37166076a07; 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.

Share the record-layout open_array awk function through lib/record-layout.sh

0 participants