Skip to content

feat(planning): fail a plan whose file:line citation does not exist, and stamp the commit it was checked at - #10066

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-10037-40213621550-1
Oct 25, 2026
Merged

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

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #10037

Summary

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

Adds scripts/check-plan-citations.sh, which reads a PLAN.md, resolves every repository-root path:line citation (single line, start-end range or comma list) against a named commit (default HEAD) and exits 1 on a missing path, a directory, line 0, a reversed range or a line past the end, printing the full commit it checked at. /planning:plan's Step 4.7 outcome gate now runs it and records that commit on a new Citations checked at: line that both plan templates carry. Refs: #6917 (W5 of that epic).

Not verified

  • Executing plugins/planning/scripts/check-plan-citations.test.sh: this lane allows no direct bash or interpreter run, and check-affected without --tests does not run suites. Its pass is predicted by hand trace and a review subagent, not observed. Left to the PR's test-bash CI lane.
  • bash plugins/skill-quality/scripts/check-skill.sh plugins/planning/skills (an issue done-when item): check-affected skipped changed-skills in this lane because it runs the checked tree's own code. Left to the PR's CI. It includes plugins/planning/tests/reattach-slice.test.sh, which requires Step 4.7
  • ci-status green on the PR, and the PR body carrying Refs: #6917 (issue done-when items): the lane opens the PR, so both are left to the PR and its CI.
  • Build/test of touched files in this run: the new script and test were not executed here (see the first entry). scripts/suite-seconds.txt has no row for the new suite, so it is counted at the 5 s default until measured.
  • Known limit, documented in the script header and SKILL.md: a dotted host and port written without a scheme (db.internal:5432) reads as a citation and needs on its line. Citations of paths with [ ] ( ) or segments (Next.js route groups, scoped packages) are skipped rather

Fix

  • plugins/planning/scripts/check-plan-citations.sh: new citation gate. Skips citations inside code fences (including fences opened in a list item or block quote) and on lines marked . Exits 2 on an unterminated fence, a non-repository path or a commit that does not resolve. Do
  • plugins/planning/scripts/check-plan-citations.test.sh: black-box test on a throwaway git fixture. Covers a missing file, a line past the end (single line, range, comma-list item, a file with no trailing newline), a directory, line zero, a reversed range, checking at an older commit, the default --re
  • plugins/planning/skills/plan/SKILL.md: Step 4.7 outcome gate runs check-plan-citations.sh --commit HEAD, requires exit 0, and says to write the printed commit into PLAN.md's Citations checked at: line. It also states the repository-root path rule, the cite-as-at-the-commit rule and when to use the
  • plugins/planning/skills/plan/templates/plan-md-anatomy.md: PLAN.md skeleton carries a Citations checked at: line under ## Plan.
  • plugins/planning/skills/plan/context/plan-template.md: Full Template carries the same Citations checked at: line.
  • .changes/planning/feat-10037-plan-citation-gate-3c9a51e7.md: minor-bump changelog fragment for the planning plugin.

Verification

The runner ran each check from the base copy against 7e54419:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-changelog-fragments: All 5 changelog fragment(s) under .changes/ are valid.
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-affected: first run failed shellcheck (SC2181 in the new test); after the fix, final run reports 10 passed, 6 skipped, 0 failed over 6 changed files.
  • cant-fail-scan --file plugins/planning/scripts/check-plan-citations.test.sh --check: PASS, no gating findings, 1 test file fully read.
  • Fresh-context review subagent (read-only) traced every test case through the script by hand and predicted all pass. Its confirmed findings were fixed: false failures on line:col, image tags, a resumed mid-token match, ${VAR} and route-group paths; list-item fences; an unclosed fence hiding citations
  • read https: //github.com/melodic-software/claude-code-plugins/issues /6917: W5 asks that a script fail a plan whose file:line citation does not exist and that plans stamp the commit they were checked at. The epic's Goal is plans that cite only code that exists; no specific observed failure is descri
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/40213621550

Left out: the items under Not verified.

Related

#10037

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

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 7e5441901d407d1339aa7941d7d6f69633f2c3a8: 0 finding(s), 0 as inline comments.

No security issues found in this pull request.

critical-findings: 0

Scope: I read all 6 changed files from .claude-lane/pr.diff and the PR context. They are the new check-plan-citations.sh and its test, the /planning:plan SKILL.md Step 4.7 addition, the two PLAN.md templates, and a changelog fragment. No changed file matches a trusted path, so no extra trusted-path scrutiny applied. No plugin.json or marketplace.json changed, so there are no manifest lines to report. I did not run the script or its test. The instruction-exception register was not consulted, because nothing in the diff deletes, narrows or softens a standing rule. SKILL.md only adds a gate.

What I checked in check-plan-citations.sh:

  • Untrusted input: PLAN.md text is the only untrusted input.
    • A cited path is limited to [A-Za-z0-9_./+-], so it carries no shell metacharacters or whitespace.
    • Citation text is only used as a quoted argument to git cat-file -t "$commit:$path" and git cat-file blob "$commit:$path". The <commit>: prefix means a leading - cannot become a git option.
    • No eval or unquoted expansion is reachable from plan text. Awk receives rows through stdin as data, not as program text.
  • Path traversal: a ../ path in a citation resolves through git's <rev>:<path> syntax, not the filesystem. Git rejects paths outside the repository, and no file contents are printed. The output is limited to pass or fail, a reason code, a last-line count and the commit SHA.
  • Option and argument handling: a PLAN.md argument starting with - is rejected as an unknown option. --commit and --repo come from the operator or the skill (--commit HEAD), not from plan content. A plan file named like x=1 would be read by awk as a variable assignment. That is only a self-inflicted failure, with no privilege boundary crossed.
  • Output: reason= and commit= values are fixed strings or a full SHA. The citation= line echoes the path, which the regex limits to safe characters, so there is no log-injection or newline vector.
  • Test script: it builds a fixture in mktemp -d, unsets GIT_DIR, GIT_WORK_TREE, GIT_CONFIG and GIT_INDEX_FILE, cleans up on exit, and does not touch the real repository.
  • PR context: it contains no embedded instructions aimed at the review lane.

Spend: this change adds no paid or billed resource. The review spent only subscription usage, so there is nothing to hold for cost.

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 7e5441901d407d1339aa7941d7d6f69633f2c3a8: 0 finding(s), 0 as inline comments.

No findings. I read the whole diff and the PR context. I did not run the script or its test, because this lane has no shell. The pass of check-plan-citations.test.sh is author-claimed, not confirmed by me.

What I checked by reading

  • Citation matching in check-plan-citations.sh: I traced the awk citation matching against the fixtures in the test. These cover valid citations, URLs, ports, times, ~, $HOME, ${ROOT}, [email protected]:3, :12abc, :99:3, image tags, route-group paths, comma lists, ranges, fences in list items and block quotes, an unterminated fence, and CRLF. Each gets the outcome the test expects.
  • Grading: The missing-path, not-a-file, line-zero, reversed and past-end grading is correct. A file with no trailing newline is counted correctly. A plan with no citations yields citations=0 failed=0.
  • Exit codes: They match the header: 2 for usage, a non-repository, a bad commit or an open fence, 1 for a failed citation, and 0 otherwise.
  • Skill wiring and templates: The Step 4.7 wiring uses the same ${CLAUDE_PLUGIN_ROOT}/scripts/... convention as the neighbouring gates. The Citations checked at: line is in both plan templates.
  • Closing issue feat(planning): fail a plan whose file:line citation does not exist, and stamp the commit it was checked at #10037: The test covers a missing file, a line past the end, and a quiet pass on a valid citation. The gate call and the checked-at line are both present under plugins/planning/skills/plan/. The remaining done-when items (check-skill.sh, ci-status, Refs: #6917 in the PR body) depend on CI and the PR body, so I could not check them here.
  • Changelog fragment: The minor bump fits a new capability. The PR adds no plugin.json or marketplace.json change, so no manifest items apply.
  • Trusted paths: None of the six changed files match them.

Not a finding: scripts/suite-seconds.txt has no row for the new suite, so it is counted at the 5 s default. The PR body already says so.

Spend: The change adds no model or CI spend beyond one more test suite in the existing bash test lane.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 7e5441901d407d1339aa7941d7d6f69633f2c3a8.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Oct 25, 2026
Merged via the queue into main with commit 697e1e6 Oct 25, 2026
40 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-10037-40213621550-1 branch October 25, 2026 19:32
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.

feat(planning): fail a plan whose file:line citation does not exist, and stamp the commit it was checked at

0 participants