Repository navigation
Keep split prompt artifacts aligned with the final prompt - #64963
Conversation
Co-authored-by: pelikhan <[email protected]>
Co-authored-by: pelikhan <[email protected]>
This reverts commit f49d9f4. Co-authored-by: pelikhan <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The split sentinel leaks into the prompt provenance template artifact.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Aligns split prompt artifacts with the processed prompt delivered to agents.
Changes:
- Preserves system/user boundaries through prompt processing.
- Applies placeholder substitutions across combined and split files.
- Adds regression coverage for synchronization and legacy behavior.
| File | Description |
|---|---|
actions/setup/js/interpolate_prompt.cjs |
Processes and rewrites split prompts. |
actions/setup/js/interpolate_prompt.test.cjs |
Tests split prompt synchronization. |
actions/setup/js/substitute_placeholders.cjs |
Substitutes placeholders across prompt artifacts. |
actions/setup/js/substitute_placeholders.test.cjs |
Tests legacy substitution behavior. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| if (content !== system + user) { | ||
| throw new Error(`${ERR_VALIDATION}: Split prompt files do not match the combined prompt`); | ||
| } | ||
| splitMarker = `\x00GH_AW_PROMPT_SPLIT_${randomUUID()}\x00`; |
There was a problem hiding this comment.
Fixed in 3493562: prompt-import-tree.json now records the original template without the internal split marker, and the regression test asserts this.
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Code Quality Reviewer completed the code quality review. No code changes or GitHub writes from the agent succeeded yet; completing PR review via final submit attempt.
|
|
✅ Ponytail Reviewer completed successfully! Warning Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs for details.
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. No ADR enforcement needed: PR does not have the implementation label and has ≤100 new lines of code in business logic directories.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff
|
Comment MemoryNote This comment is managed by comment memory.It stores persistent context for this thread in the code block at the top of this comment.
|
There was a problem hiding this comment.
Request changes
The split-artifact sync fix is headed in the right direction, but there are still blocking correctness gaps in the changed lines.
Blocking themes
- The temporary split marker is injected into
contentbeforeprompt-import-tree.jsoncapturesimportTree.template, so the provenance artifact no longer matches the real template/prompt boundary behavior. substitute_placeholders.cjsonly updatessystem.txt/user.txtwhen the combined file is literally namedprompt.txt, which regresses customGH_AW_PROMPTpaths back to stale split artifacts.
Those two cases mean the PR still does not reliably keep the derived prompt artifacts aligned with the final prompt across supported configurations.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 37.5 AIC · ⌖ 7.31 AIC · ⊞ 20.2K
Comment /review to run again
| const errorMessage = getErrorMessage(error); | ||
| throw new Error(`${ERR_SYSTEM}: Failed to read file ${file}: ${errorMessage}`); | ||
| } | ||
| const splitPaths = path.basename(file) === "prompt.txt" ? ["system.txt", "user.txt"].map(name => path.join(path.dirname(file), name)) : []; |
There was a problem hiding this comment.
Hard-coding split-mode to path.basename(file) === "prompt.txt" breaks any workflow that writes the combined prompt under a different filename, because create_prompt still emits sibling system.txt/user.txt files and this code will now leave them stale after placeholder substitution.
💡 Why this is a merge blocker
The feature goal here is to keep the split artifacts aligned with the final prompt, but this branch only does that for the default filename. GH_AW_PROMPT is configurable, and create_prompt.cjs writes system.txt/user.txt next to whatever prompt path the caller chose, so a custom path regresses right back to the old divergence bug.
A safer check is to discover split artifacts by sibling existence (and ideally reuse the same combined-vs-split validation you already added) instead of keying the behavior off the prompt filename.
const splitPaths = ["system.txt", "user.txt"].map(name => path.join(path.dirname(file), name));
const hasSplit = splitPaths.every(splitPath => fs.existsSync(splitPath));There was a problem hiding this comment.
Fixed in 3493562: sibling system.txt and user.txt are now detected for custom combined-prompt filenames, with a regression test confirming all three remain aligned.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs and /tdd — requesting changes because an existing reviewer-flagged bug is still unresolved.
📋 Key Themes & Highlights
Key Themes
- Root cause not fully addressed:
importTree.templateis captured after the split-marker is injected, so split-prompt runs record a random NUL-delimited UUID inprompt-import-tree.jsoninstead of the real template. This directly undermines the stated goal of giving downstream threat detection a reliable template-vs-rendered diff. - Missing regression tests for new error paths: both new validation throws (
Split prompt files do not match the combined promptandPrompt split boundary was lost during processing) have no test coverage, despite being the exact failure modes this PR is designed to catch.
Positive Highlights
- ✅ Good core idea: threading a unique split marker through import/render/placeholder steps keeps
system.txt/user.txtprovably consistent withprompt.txt. - ✅
substitute_placeholders.cjscorrectly preserves legacy single-file behavior when no split files are present, and the basename("prompt.txt") gate matches the one consistent naming convention used across all callers in the repo. - ✅ Decent test added for the happy-path round trip through imports + conditionals + substitution.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 106.4 AIC · ⌖ 14.7 AIC · ⊞ 10K
Comment /matt to run again
Comments that could not be inline-anchored
actions/setup/js/interpolate_prompt.cjs:127
[/diagnosing-bugs] This existing issue (flagged by Copilot's earlier review) is still unresolved: importTree.template captures content after the split marker is injected above, so every split-prompt workflow writes a random NUL-delimited UUID into prompt-import-tree.json, even when no split occurred for that run previously. Downstream consumers (threat detection) diff prompt-template.txt against the rendered prompt — a non-reproducible per-run UUID embedded in the recorded templat…
actions/setup/js/interpolate_prompt.cjs:113
[/tdd] The new validation/error paths this fix introduces aren't covered by tests: the "Split prompt files do not match" mismatch check (line 113) and the "Prompt split boundary was lost" check (line 299, triggered when a processing step strips/duplicates the NUL marker) have no corresponding test cases. These are exactly the regressions this PR is meant to guard against.
<details>
<summary>💡 Suggested tests</summary>
it("throws when system.txt + user.txt no longer matches prompt.t…
</details>|
@copilot please address the requested review feedback and then run the
|
Co-authored-by: gh-aw-bot <[email protected]>
Addressed both review findings in |
|
@copilot Quick triage nudge: please review any open feedback, refresh this branch if needed, and run the
|
Ran |
Co-authored-by: gh-aw-bot <[email protected]>
|
@copilot This PR looks stalled and could use a maintainer-ready refresh. Please review unresolved feedback/check state, update the branch if needed, and run the
|
Co-authored-by: gh-aw-bot <[email protected]>
Fixed the remaining inline-boundary blocker in |
|
🎉 This pull request is included in a new release. Release: |

system.txtanduser.txtwere captured before runtime imports, interpolation, template rendering, and placeholder substitution changedprompt.txt. The uploaded split artifacts could therefore differ from the prompt given to the agent.prompt.txt.Branch refresh attempted by PR Sous Chef. Run: https://github.com/github/gh-aw/actions/runs/36998188131