Skip to content

Add custom validation hooks for repo and cache memory - #52053

Open
pelikhan with Copilot wants to merge 19 commits into
mainfrom
copilot/add-custom-validation-extension
Open

Add custom validation hooks for repo and cache memory#52053
pelikhan with Copilot wants to merge 19 commits into
mainfrom
copilot/add-custom-validation-extension

Conversation

Copilot AI commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

repo-memory and cache-memory only enforced generic storage limits, so structurally valid but domain-invalid state could be persisted and break later runs. Workflows can now define a per-memory JavaScript validator that runs at the persistence boundary.

  • Configuration
    • Added validation.script and optional validation.timeout to repo-memory and cache-memory entries.
    • Updated workflow schema and reference docs with execution context, timeout, environment, and failure behavior.
tools:
  repo-memory:
    validation:
      timeout: 30
      script: |
        const state = JSON.parse(fs.readFileSync(path.join(memoryRoot, "state.json"), "utf8"));
        if (state.digest.length !== 16) throw new Error("digest must be 16 chars");
  • Runtime validation

    • Runs validators over the complete configured memory root.
    • Runs after repo-memory format-json normalization.
    • Captures validator stdout/stderr separately from built-in storage validation.
    • Treats exceptions, false, nonzero exit, timeout, or missing script as persistence failures.
  • Persistence gating

    • Gates repo-memory artifact upload on successful custom validation.
    • Revalidates in the repo-memory push job before commit.
    • Gates cache-memory artifact upload / cache save on successful validation.
    • Revalidates cache-memory in update_cache_memory before actions/cache/save.
  • Coverage

    • Added focused Go and JS tests for success, failure, timeout, missing validator, multiple memory IDs, and post-format validation ordering.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 10.1 AIC · ⌖ 5.7 AIC · ⊞ 8.5K ·
Comment /souschef to run again


Run report: https://github.com/github/gh-aw/actions/runs/31554759452> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 13.6 AIC · ⌖ 7.61 AIC · ⊞ 8.5K ·

Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 10.6 AIC · ⌖ 5.36 AIC · ⊞ 8.5K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 13.5 AIC · ⌖ 5.2 AIC · ⊞ 8.5K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 8.74 AIC · ⌖ 6.38 AIC · ⊞ 8.5K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 18.5 AIC · ⌖ 6.56 AIC · ⊞ 8.5K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 11.1 AIC · ⌖ 5.23 AIC · ⊞ 8.5K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 8.32 AIC · ⌖ 5.15 AIC · ⊞ 8.5K ·
Comment /souschef to run again


branch refresh requested in run https://github.com/github/gh-aw/actions/runs/31644728185> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 18.5 AIC · ⌖ 5.27 AIC · ⊞ 8.5K ·

Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 21 AIC · ⌖ 5.14 AIC · ⊞ 8.5K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 17.4 AIC · ⌖ 5.14 AIC · ⊞ 8.5K ·
Comment /souschef to run again

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for starting this work! 🚀 This PR follows the project's agentic development process and aligns with the requirements in #52018.

As a draft/WIP PR with no file changes yet, here are some pointers as implementation progresses:

  • Checklist tracking — Your task list in the PR body is clear. As you work through the implementation steps, update the checkboxes to keep reviewers oriented.
  • Add tests alongside implementation — The checklist mentions focused tests for success, failure, timeout, missing validator, multiple IDs, and post-format validation ordering. These should land with the core implementation.
  • Document validator execution context — Issue repo-memory and cache-memory: add a custom validation extension point before accepting updates #52018 mentions security requirements: working directory, available mounts/environment, timeout, and security restrictions should be well-documented.

The PR is on track. Once implementation begins and files start changing, reviewers will have substance to evaluate against the validation extension requirements from #52018.

Implement the custom validation extension point for repo-memory updates following the requirements in github/gh-aw#52018.

Acceptance criteria:
1. A repo-memory workflow can configure a domain validator via validation.script and timeout config
2. A fixture with valid generic limits but invalid domain content is rejected by push_repo_memory
3. No repo-memory artifact or branch commit is produced after custom validation fails
4. Tests cover success, nonzero exit, timeout, missing validator, multiple memory IDs, and post-format ordering
5. The success message distinguishes generic storage validation from custom domain validation

Apply to both repo-memory and cache-memory.

Generated by ✅ Contribution Check · auto · 49.6 AIC · ⌖ 3.67 AIC · ⊞ 8.8K ·

Copilot AI and others added 3 commits August 11, 2026 13:30
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add custom validation extension point for repo memory updates Add custom validation hooks for repo and cache memory Aug 11, 2026
Copilot AI requested a review from pelikhan August 11, 2026 13:37
@pelikhan
pelikhan marked this pull request as ready for review August 11, 2026 13:44
Copilot AI balanced review requested due to automatic review settings August 11, 2026 13:44
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot the compiler update detector should flag changes to these script fields in the compile update security report

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer failed during the skills-based review.

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.

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

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel failed during test quality analysis.

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.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ failed during design decision gate check.

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.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed during code quality review.

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.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • api.individual.githubcopilot.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.individual.githubcopilot.com"

See Network Configuration for more information.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer failed. Please review the logs for details.

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 #52053

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.

Pull request overview

Adds configurable JavaScript validation hooks for repo-memory and cache-memory persistence.

Changes:

  • Parses and documents validation scripts and timeouts.
  • Runs validators before artifact upload, cache save, and repository commit.
  • Adds focused compiler and runtime tests.
Show a summary per file
File Description
pkg/workflow/safe_outputs_config_generation.go Passes validation configuration to safe outputs.
pkg/workflow/repo_memory.go Generates repo-memory validation gates.
pkg/workflow/repo_memory_test.go Tests repo-memory generation.
pkg/workflow/memory_validation_config.go Parses shared validation configuration.
pkg/workflow/compiler_github_actions_steps.go Removes obsolete step helper.
pkg/workflow/cache.go Generates cache validation and save gates.
pkg/workflow/cache_memory_syntax_test.go Tests cache validation generation.
pkg/parser/schemas/main_workflow_schema.json Defines validation schema.
docs/src/content/docs/reference/repo-memory.md Documents repo-memory validators.
docs/src/content/docs/reference/cache-memory.md Documents cache-memory validators.
actions/setup/js/safe_outputs_handlers.test.cjs Tests persistence-boundary validation.
actions/setup/js/safe_outputs_handlers.cjs Runs repo-memory validators safely.
actions/setup/js/push_repo_memory.cjs Revalidates before repository commit.
actions/setup/js/memory_custom_validation.test.cjs Tests validator execution utilities.
actions/setup/js/memory_custom_validation.cjs Implements validator execution and formatting.

Review details

Tip

Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 15/15 changed files
  • Comments generated: 4
  • Review effort level: Balanced

Comment thread pkg/workflow/cache.go Outdated
}

func cacheMemoryValidationStepID(cacheID string) string {
return strings.ReplaceAll("validate_cache_memory_"+cacheID, "-", "_")
Comment thread pkg/workflow/repo_memory.go Outdated
}

func repoMemoryValidationStepID(memoryID string) string {
return strings.ReplaceAll("validate_repo_memory_"+memoryID, "-", "_")
Comment on lines +188 to +192
const result = childProcess.spawnSync(process.execPath, [scriptPath], {
cwd: options.memoryDir,
encoding: "utf8",
env: sanitizedValidationEnv(process.env),
timeout: timeoutMs,
Comment on lines +53 to +54
case float64:
return validateMemoryValidationTimeout(int(v), fieldPath)
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please inspect the latest branch state, refresh the branch if needed, and run the pr-finisher skill before handing this PR back to maintainers.

No unresolved review threads were found.
No failed checks were reported in the compact candidate set for this run.
Branch update was requested automatically for this run when GitHub allows it.

Run context: https://github.com/github/gh-aw/actions/runs/31636098279

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 8.32 AIC · ⌖ 5.15 AIC · ⊞ 8.5K ·
Comment /souschef to run again

Comment thread .github/workflows/ai-moderator.lock.yml Outdated
const result = validateMemoryFiles('/tmp/gh-aw/cache-memory', 'cache', allowedExtensions);
if (!result.valid) {
core.setFailed(`File type validation failed: Found $${result.invalidFiles.length} file(s) with invalid extensions. Only .json are allowed.`);
const { runCustomMemoryValidation, writeValidationMarker, clearValidationMarker } = require('${{ runner.temp }}/gh-aw/actions/memory_custom_validation.cjs');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot refactor code into a file in actions/setup/js

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.

Refactored in 6332309: generated validation steps now call actions/setup/js/validate_memory_step.cjs; related workflow locks were recompiled and focused tests pass.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan August 12, 2026 22:02
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please inspect the latest branch state, resolve any already-addressed review threads that remain open if tooling allows, refresh the branch if needed, and run the pr-finisher skill before handing this PR back to maintainers.

Open review threads with author follow-up detected:

No failed checks were reported in the compact candidate set for this run.
Branch update was requested automatically for this run when GitHub allows it.

Run context: https://github.com/github/gh-aw/actions/runs/31644728185

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 18.5 AIC · ⌖ 5.27 AIC · ⊞ 8.5K ·
Comment /souschef to run again

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage Summary

Total score: 55/100
Breakdown: Impact 35 (large feature, 31 files) + Urgency 8 (no blocker) + Quality 12 (CI green, comment-only review, high risk) -> DEFER (needs full review, high risk)

Automated triage — see labels applied for classification. Full report in the triage issue.

Generated by 🔧 PR Triage Agent · auto · 43.1 AIC · ⌖ 2.43 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

Category: feature | Risk: high | Priority: medium | Score: 55/100

Score breakdown: impact 30/50, urgency 10/30, quality 15/20

CI: green

Recommended action: defer

Large feature (1694 line diff, 31 files); CI green but high risk warrants careful human review, not fast-tracked.

Automated triage — run 52053

Generated by 🔧 PR Triage Agent · auto · 67.2 AIC · ⌖ 2.77 AIC · ⊞ 7.8K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please inspect the latest branch state, refresh the branch if needed, and run the pr-finisher skill before handing this PR back to maintainers.

No unresolved review threads were found.
No failed checks were included in the compact candidate set.

Branch update was requested automatically for this run when GitHub allows it.

Run context: https://github.com/github/gh-aw/actions/runs/31677429233

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.5 AIC · ⌖ 5.13 AIC · ⊞ 8.5K ·
Comment /souschef to run again

…lidation-extension

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please inspect the latest branch state, refresh the branch if needed, and run the pr-finisher skill before handing this PR back to maintainers.

No unresolved review threads were found....

Refreshed from current main in a37a30b3c0. Local formatting, linting, unit/full tests, recompilation, and the final report gate pass.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please inspect the latest branch state, refresh the branch if needed, and run the pr-finisher skill before handing this PR back to maintainers.

No unresolved review threads were found.
No failed checks were included in the compact candidate set.
Branch update was requested by sous-chef for run https://github.com/github/gh-aw/actions/runs/31680036173.

Generated by PR Sous Chef
Comment /souschef to run again

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 21 AIC · ⌖ 5.14 AIC · ⊞ 8.5K ·
Comment /souschef to run again

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please inspect the latest branch state, refresh the branch if needed, and run the pr-finisher skill before handing this PR back to maintainers.

No unresolved review threads were found....

The branch already contains current main (b2ef1f3), so no refresh was needed. The cited run succeeded; current-head CWI is awaiting approval with zero failed jobs.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please inspect the latest branch state and run the pr-finisher skill before handing this PR back to maintainers.

No unresolved review threads were found.
No failed checks were included in the compact candidate set.
Branch update was requested by sous-chef for run https://github.com/github/gh-aw/actions/runs/31683038335.

Generated by PR Sous Chef
Comment /souschef to run again

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 17.4 AIC · ⌖ 5.14 AIC · ⊞ 8.5K ·
Comment /souschef to run again

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.

repo-memory and cache-memory: add a custom validation extension point before accepting updates

4 participants