Skip to content

Deduplicate JavaScript harness prompt and permission handling - #75733

Merged
pelikhan merged 4 commits into
mainfrom
copilot/refactor-duplicated-logic
Nov 7, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/refactor-duplicated-logic

Conversation

Copilot AI commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Extract equivalent behavior from the engine harnesses without unifying their distinct retry and session policies.

  • Permission failures: Share terminal handling across Copilot, Claude, and Codex. Preserve staged outputs, Claude’s structured denial commands, and safeoutputs CLI diagnostics.
  • Prompt input: Share Claude/Codex prompt-file resolution while retaining their delivery contracts and Codex’s legacy missing-path tolerance.
  • Scope: Leave Copilot’s binary/large-prompt handling and Pi/Agy/shell lifecycles unchanged.
  • Regression coverage: Add 28 cases for prompt edge cases, diagnostic emission failures, and subprocess-level no-retry/output-preservation behavior.

Copilot AI changed the title Refactor duplicated JavaScript harness prompt and permission handling Deduplicate JavaScript harness prompt and permission handling Nov 7, 2026
Copilot AI requested a review from pelikhan November 7, 2026 18:49
@pelikhan
pelikhan marked this pull request as ready for review November 7, 2026 18:52
Copilot AI adaptive review requested due to automatic review settings November 7, 2026 18:52
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · routed: gpt56 max · ~4 AIC · ⌖ ~1 AIC · ⊞ 118 · ◷

Generated by Ponytail Reviewer for #75733

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 7, 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 Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Specification Reviewer · gpt56 · ~2 AIC · ⌖ ~2 AIC · ⊞ 1.7K · ◷

Generated by PR Specification Reviewer for #75733

@github-actions

github-actions Bot commented Nov 7, 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.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · routed: opus55 xhigh · ~13 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

log(`attempt ${attempt + 1}: detected numerous permission-denied issues but safe-outputs already contain expected output — suppressing terminal verdict (false-red: core work succeeded)`);
return { action: "stop", exitCode: 0 };
}
emitMissingToolPermissionIssue({ deniedCommands: deniedCommands ?? extractDeniedCommands(output), permissionOutput: output, logger: log });

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

Static review completed for the changed harness refactor. I found no actionable correctness, regression, or maintainability issues in the changed lines. The specialist pass was unavailable because its file-read attempt was denied; this verdict is based on the independent diff and targeted source review.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~2 AIC · ⊞ 1.6K
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.

Skills-Based Review 🧠

Applied /codebase-design and /tdd. The refactor is behaviour-preserving on the paths I checked, so this is a comment-only review with two follow-ups.

📋 Verification and key themes

Verified

  • The shared prompt helper (harness_prompt_input.cjs) keeps strict mode for Claude and legacy tolerance for Codex. I smoke-tested it: empty prompt, missing path, directory path, and repeated --prompt-file (last wins) all match the diff.
  • The Claude call site still passes denials.commands directly, as before.
  • The Codex hasExpectedSafeOutputs suppression guard survives inside stopForPermissionDenied.
  • The payload builder does not leak raw output when the structured command list is empty.

Key themes

  • Hidden text-parsing fallback: the ?? in harness_failure_handling.cjs re-parses tool-result text for Copilot and Codex (inline comment).
  • Duplicate test coverage: the staged true/false matrix is repeated in three test files (inline comment).
  • Dead import: claude_harness.cjs:40 still has const fs = require("fs"). Nothing in the file uses fs. after this refactor. The line is outside the diff hunks, so I could not comment on it inline. Please remove it.
  • Unverified: I did not run the vitest suites. Dependency install failed in this sandbox, so the test results are unconfirmed.

Lock file

enterprise-docs-audit.lock.yml appears in the PR head commit. It is generated output, so confirm it came from make recompile and was not hand-edited.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~9 AIC · ⌖ ~2 AIC · ⊞ 5.4K
Comment /matt to run again

log(`attempt ${attempt + 1}: detected numerous permission-denied issues but safe-outputs already contain expected output — suppressing terminal verdict (false-red: core work succeeded)`);
return { action: "stop", exitCode: 0 };
}
emitMissingToolPermissionIssue({ deniedCommands: deniedCommands ?? extractDeniedCommands(output), permissionOutput: output, logger: log });

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.

[/codebase-design] The deniedCommands ?? extractDeniedCommands(output) fallback makes this helper parse raw tool-result text whenever a caller omits structured commands. Copilot and Codex still rely on that path. The old code did the same, so this is not a regression, but the trust boundary is now hidden in a shared helper. Make deniedCommands required and have Copilot and Codex call extractDeniedCommands(result.output) at their call sites, so the text parsing is visible where it happens.

💡 Suggested call-site change
return stopForPermissionDenied({ attempt, output: result.output, safeOutputsPath, log, deniedCommands: extractDeniedCommands(result.output) });

The helper then always receives a command list, and the text fallback goes away.

@copilot please address this.

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.

Updated in 3c25702. The shared helper now requires deniedCommands, and Copilot and Codex call extractDeniedCommands(result.output) explicitly at their call sites.

}

describe("claude_harness.cjs", () => {
it.each([false, true])("handles structured permission failures without replaying work (staged output: %s)", staged => {

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.

[/tdd] This it.each repeats the staged true/false matrix that harness_failure_handling.test.cjs now covers directly. codex_harness.test.cjs:151 repeats it too. Keep the harness-level assertions that prove work is not replayed, and drop the duplicated staged-output checks.

💡 Why keep one harness test

The shared suite covers the verdict logic. Each harness test only needs to prove the harness calls the shared helper and does not replay work, so the extra copies add maintenance cost without new coverage.

@copilot please address this.

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.

Updated in 3c25702. The harness-level cases now verify terminal handling without replay; staged-output behavior remains covered directly in harness_failure_handling.test.cjs.

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.

🟡 Changes recommended

An explicit empty safeOutputsPath still allows the safeoutputs CLI to run via the environment fallback, leaving the completed-output check and diagnostic-emission gate inconsistent.

1 open issue
What changed in this PR

Deduplicates prompt loading and permission-failure handling in gh-aw’s JavaScript harnesses while preserving engine-specific retry, session, and prompt-delivery policies.

Changes:

  • Share permission-failure handling across Copilot, Claude, and Codex, plus prompt-file resolution across Claude and Codex.
  • Add regression coverage for prompt edge cases, diagnostic failures, and output preservation without retries.
  • Point enterprise documentation threat detection at a dedicated input directory.
File Description
actions/​setup/​js/​harness_prompt_input.test.cjs Tests shared prompt parsing and engine delivery contracts.
actions/​setup/​js/​harness_prompt_input.cjs Extracts shared prompt-file resolution.
actions/​setup/​js/​harness_failure_handling.test.cjs Tests terminal permission handling and diagnostic emission.
actions/​setup/​js/​harness_failure_handling.cjs Extracts shared permission-failure handling.
actions/​setup/​js/​copilot_harness.cjs Delegates permission failures to the shared helper.
actions/​setup/​js/​codex_harness.test.cjs Adds no-retry and staged-output regression cases.
actions/​setup/​js/​codex_harness.cjs Uses shared helpers while retaining legacy prompt tolerance.
actions/​setup/​js/​claude_harness.test.cjs Adds structured-denial and staged-output regression cases.
actions/​setup/​js/​claude_harness.cjs Uses shared helpers while retaining structured denial commands.
.github/​workflows/​enterprise-docs-audit.lock.yml Updates the threat-detection input directory.

Review effort: Max (auto)

log(`attempt ${attempt + 1}: detected numerous permission-denied issues but safe-outputs already contain expected output — suppressing terminal verdict (false-red: core work succeeded)`);
return { action: "stop", exitCode: 0 };
}
emitMissingToolPermissionIssue({ deniedCommands: deniedCommands ?? extractDeniedCommands(output), permissionOutput: output, logger: log });
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/harness_failure_handling.cjs:25): [/codebase-design] The deniedCommands ?? extractDeniedCommands(output) fallback makes this helper parse raw tool-result text whenever a caller omits structured commands. Copilot and Codex still rely on that path. The old code did the same, so this is not a regression, but the trust boundary is now hidden in a shared helper. Make deniedCommands required and have Copilot and Codex call extractDeniedCommands(result.output) at their call sites, so the text parsing is visible where it happens. - Deduplicate JavaScript harness prompt and permission handling #75733 (comment)
  3. Review (actions/setup/js/claude_harness.test.cjs:88): [/tdd] This it.each repeats the staged true/false matrix that harness_failure_handling.test.cjs now covers directly. codex_harness.test.cjs:151 repeats it too. Keep the harness-level assertions that prove work is not replayed, and drop the duplicated staged-output checks. - Deduplicate JavaScript harness prompt and permission handling #75733 (comment)
  4. Fix failing check JS Tests (shard 7/8) (FAILURE): https://github.com/github/gh-aw/actions/runs/42403476304/job/128496162497.

Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI.

Sous-chef requested-head: de9b716
Sous-chef requested-work: 47f188a12b316525c2202f4f75b82185d76be0a140c0f99eae185cf2b7d8acb1 5226edb88d3ae175497855a566b0e5f56978d115285e376a3a9a074d8f27511e 686cce95c15ea7e0187f499a2983a6eb4d650136c21294bea4a01b70998e749a
Sous-chef requested-state: 9c12e075f41bbd54243c353f7ec1803e5249dc714849f4d897823cbd62b74478

Generated by 👨🍳 PR Sous Chef · pi · haiku45 · ~10 AIC · ⌖ ~14 AIC · ⊞ 1.2K · ◷
Comment /souschef to run again

Copilot AI commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot assignment requested for the following outstanding work:...

Starting the requested work: I’ll update this branch from main, address the harness feedback, and inspect the failing JavaScript test shard. I will not trigger CI or merge.

Sous-chef requested-head: de9b716
Sous-chef requested-work: 47f188a12b316525c2202f4f75b82185d76be0a140c0f99eae185cf2b7d8acb1 5226edb88d3ae175497855a566b0e5f56978d115285e376a3a9a074d8f27511e 686cce95c15ea7e0187f499a2983a6eb4d650136c21294bea4a01b70998e749a
Sous-chef requested-state: 9c12e075f41bbd54243c353f7ec1803e5249dc714849f4d897823cbd62b74478

log(`attempt ${attempt + 1}: detected numerous permission-denied issues but safe-outputs already contain expected output — suppressing terminal verdict (false-red: core work succeeded)`);
return { action: "stop", exitCode: 0 };
}
emitMissingToolPermissionIssue({ deniedCommands, permissionOutput: output, logger: log });
@pelikhan
pelikhan merged commit dd9fca5 into main Nov 7, 2026
48 checks passed
@pelikhan
pelikhan deleted the copilot/refactor-duplicated-logic branch November 7, 2026 19:48
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.2

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.

5 participants