Skip to content

Fix wrapped gallery classification responses - #94

Open
Jay Gordon (jaydestro) wants to merge 2 commits into
AzureCosmosDB:mainfrom
jaydestro:fix/gallery-classification-response
Open

Jay Gordon (jaydestro) wants to merge 2 commits into
AzureCosmosDB:mainfrom
jaydestro:fix/gallery-classification-response

Conversation

@jaydestro

Copy link
Copy Markdown
Collaborator

Summary

  • extract the strict JSON object when Copilot CLI wraps its response in quotes or explanatory text
  • retain exact schema, index, URL, verdict, and evidence validation after extraction
  • fail the audit explicitly after both classification attempts fail instead of returning a misleading successful run with no proposal artifact
  • add regression coverage for the response shape observed in run 36613869585

Root cause

Run 36613869585 discovered 31 candidates, but Copilot classification failed twice with Unexpected character "'" at position 1. That set run-metadata.complete to false and omitted promotion-result.json. The actionable gate therefore uploaded no proposal artifact, causing downstream run 36614297302 to skip Publish proposal issue.

Validation

  • npm run test:gallery-audit (67 tests passed)
  • npm run build
  • git diff --check

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

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

JSON extraction mishandles wrappers containing braces, and the new failure behavior lacks a behavioral test.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Improves gallery audit reliability when Copilot returns wrapped classification JSON.

Changes:

  • Extracts JSON from wrapped responses.
  • Fails audits after repeated classification failures.
  • Adds regression and workflow checks.
File Description
scripts/​gallery-audit/​copilot.mjs Adds wrapped-object extraction.
scripts/​gallery-audit/​index.mjs Fails incomplete classifications explicitly.
scripts/​gallery-audit/​test/​audit.test.mjs Tests wrapped responses.
scripts/​gallery-audit/​test/​configuration.test.mjs Checks failure-path configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +67 to +70
const start = stripped.indexOf('{');
const end = stripped.lastIndexOf('}');
if (start === -1 || end < start) return stripped;
return stripped.slice(start, end + 1);
assert.match(audit, /r\.additions\?\.length[\s\S]*r\.updates\?\.length[\s\S]*r\.retirements\?\.length/);
assert.match(audit, /steps\.actionable\.outputs\.available == 'true'/);
assert.doesNotMatch(audit, /contents: write|issues: write|git push|gh issue create/);
assert.match(read('scripts/gallery-audit/index.mjs'), /Copilot classification incomplete after/);
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jaydestro

Copy link
Copy Markdown
Collaborator Author

Live failed-run replay completed

Before requesting review, I replayed the exact artifacts from failed audit run 36613869585 through this branch using the same pinned Copilot CLI version (1.0.85) and curator skill/checksum as Actions.

Results:

  • all 31 discovered candidates were classified successfully;
  • promotion-result.json and promotion-summary.md were generated;
  • actionable proposal count: 23 (20 additions, 0 URL updates, 3 retirements);
  • proposal issue payload size: 32,862 bytes;
  • the generated catalogs passed all 67 audit tests;
  • the generated site passed npm run build;
  • replay-only catalog, output, skill, and CLI changes were restored afterward.

The replay also changed Copilot prompt delivery from a command-line argument to documented piped stdin, avoiding Windows command-line limits while retaining the same agent and restrictions on Linux Actions.

@jaydestro

Copy link
Copy Markdown
Collaborator Author

Full end-to-end staging test passed

Tested the complete operator flow in jaydestro/gallery using commit 369c1fd as the temporary trusted default branch:

  1. Audit workflow succeeded: https://github.com/jaydestro/gallery/actions/runs/36617262461
  2. Proposal artifact uploaded: gallery-content-proposal-36617262461
  3. Publisher workflow created the issue: https://github.com/jaydestro/gallery/actions/runs/36617677064/attempts/2
  4. Generated proposal issue: Gallery content proposal 36617262461 jaydestro/gallery#23
  5. Edited the issue down to one retained addition.
  6. Assigned the edited issue to Copilot.
  7. Copilot created a draft PR: Add Azure Cosmos DB partitioning documentation jaydestro/gallery#24
  8. The PR changed only static/templates.json with the retained card.
  9. Independently cloned the exact agent branch and verified:
    • npm run test:gallery-audit: 67/67 passed
    • npm run build: passed
  10. Closed the test PR and issue without merging, deleted the agent test branch, and restored the staging fork's original default branch, Issues setting, and rulesets.

The publisher's first staging attempt failed only because Issues were disabled on the fork. After enabling the repository feature, rerunning the unchanged publisher succeeded. Issues are already enabled in AzureCosmosDB/gallery.

This branch has not been deployed

No deployments
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.

2 participants