Skip to content

Keep split prompt artifacts aligned with the final prompt - #64963

Merged
pelikhan merged 7 commits into
mainfrom
copilot/apply-comment-feedback-64949
Oct 2, 2026
Merged

pelikhan merged 7 commits into
mainfrom
copilot/apply-comment-feedback-64949

Conversation

Copilot AI commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

system.txt and user.txt were captured before runtime imports, interpolation, template rendering, and placeholder substitution changed prompt.txt. The uploaded split artifacts could therefore differ from the prompt given to the agent.

  • Prompt processing: Preserve the system/user boundary through runtime processing, then refresh both split files from the processed content.
  • Placeholder substitution: Apply substitutions to all three files while retaining the existing behavior when split files are absent.
  • Regression coverage: Check that processed system and user content concatenates to the final prompt.txt.

Branch refresh attempted by PR Sous Chef. Run: https://github.com/github/gh-aw/actions/runs/36998188131

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 15.6 AIC · ⌖ 8.62 AIC · ⊞ 9.7K · ◷
Comment /souschef to run again

Copilot AI changed the title Keep split activation prompt artifacts synchronized Keep split prompt artifacts aligned with the final prompt Oct 2, 2026
Copilot AI requested a review from pelikhan October 2, 2026 07:39
@pelikhan
pelikhan marked this pull request as ready for review October 2, 2026 07:44
Copilot AI balanced review requested due to automatic review settings October 2, 2026 07:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The split sentinel leaks into the prompt provenance template artifact.

Review effort: Balanced
Findings: 1 Medium severity

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.

Comment thread actions/setup/js/interpolate_prompt.cjs Outdated
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`;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3493562: prompt-import-tree.json now records the original template without the internal split marker, and the regression test asserts this.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ 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.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ 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 happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Generated by Ponytail Reviewer for #64963

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ 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.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-10-02T07:53:33.863+00:00
review_event: REQUEST_CHANGES
top_themes:
  - split marker leaks into prompt-import-tree template artifact
  - custom GH_AW_PROMPT paths leave system.txt/user.txt stale after placeholder substitution
files_reviewed:
  - actions/setup/js/interpolate_prompt.cjs
  - actions/setup/js/interpolate_prompt.test.cjs
  - actions/setup/js/substitute_placeholders.cjs
  - actions/setup/js/substitute_placeholders.test.cjs
comment_count: 1

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 37.5 AIC · ⌖ 7.31 AIC · ⊞ 20.2K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 content before prompt-import-tree.json captures importTree.template, so the provenance artifact no longer matches the real template/prompt boundary behavior.
  • substitute_placeholders.cjs only updates system.txt/user.txt when the combined file is literally named prompt.txt, which regresses custom GH_AW_PROMPT paths 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)) : [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.template is captured after the split-marker is injected, so split-prompt runs record a random NUL-delimited UUID in prompt-import-tree.json instead 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 prompt and Prompt 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.txt provably consistent with prompt.txt.
  • ✅ substitute_placeholders.cjs correctly 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(&quot;throws when system.txt + user.txt no longer matches prompt.t…

</details>

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please address the requested review feedback and then run the pr-finisher skill before handing this PR back for maintainer investigation.

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 9.99 AIC · ⌖ 8.42 AIC · ⊞ 9.7K · ◷
Comment /souschef to run again

Copilot AI commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please address the requested review feedback and then run the pr-finisher skill before handing this PR back for maintainer investigation.

Generated by [👨‍🍳 PR Sous Chef](https://...

Addressed both review findings in 3493562 and ran the pr-finisher checks. Local JS tests, lint, and workflow recompilation passed; make test still hits unrelated stale Firewall/MCP Gateway version expectations in pkg/constants. CI must be re-triggered by a maintainer after this push.

Copilot AI requested a review from gh-aw-bot October 2, 2026 09:31
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage nudge: please review any open feedback, refresh this branch if needed, and run the pr-finisher skill to move this PR toward merge readiness.

  • Branch refresh was attempted by sous-chef.
  • If there are unresolved review threads or failing checks, address those first.

Generated by 👨🍳 PR Sous Chef

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 15.6 AIC · ⌖ 8.62 AIC · ⊞ 9.7K · ◷
Comment /souschef to run again

Copilot AI commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Quick triage nudge: please review any open feedback, refresh this branch if needed, and run the pr-finisher skill to move this PR toward merge readiness.

  • Branch refresh was attempted by ...

Ran pr-finisher and verified the requested fixes/tests in 3493562; no branch refresh or new edits were needed. All 65 focused JS tests, formatting, lint, and 301 workflow compilations passed. Full Go tests still fail on unrelated Firewall/MCP Gateway version expectations. Both previously answered review threads remain unresolved because authenticated thread-resolution tooling is unavailable. I also reproduced another blocker: the split sentinel hides first-line inline agent/skill headings in the user prompt, causing skipped extraction or orphan-end errors. Automated review was unavailable and CodeQL timed out. This PR is not merge-ready; the inline-boundary bug, outstanding review disposition, and CI approval need maintainer investigation.

Co-authored-by: gh-aw-bot <[email protected]>
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@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 pr-finisher skill before handing back.

  • Branch refresh may help pick up the latest base changes.
  • Please address any outstanding reviewer notes and re-run the relevant checks.

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 18.9 AIC · ⌖ 8.49 AIC · ⊞ 9.2K · ◷
Comment /souschef to run again

Copilot AI commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@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 pr-finisher skill before handing back...

Fixed the remaining inline-boundary blocker in 43137df: the internal split marker now sits on its own line, so ## agent: / ## skill: headings and template blocks at the start of user.txt are detected again. I added a regression test that fails without the fix. Local pre-PR validation passed (format, lint, impacted unit tests, 301 workflow recompiles). The branch was already up to date. I didn't commit the unrelated action_pins.json changes that recompiling produced. CI on this commit hasn't run yet, so a maintainer needs to re-trigger it. The two earlier review threads were answered in 3493562 but are still unresolved because I can't resolve threads from this environment.

@pelikhan
pelikhan merged commit 2758eb4 into main Oct 2, 2026
11 checks passed
@pelikhan
pelikhan deleted the copilot/apply-comment-feedback-64949 branch October 2, 2026 14:58
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.90.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants