Skip to content

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

Open
pelikhan with Copilot wants to merge 11 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 11 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

@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>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

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

Implemented in 2f496b2. Safe-update reports now flag added, modified, and removed repo/cache memory validation scripts using manifest-stored SHA-256 hashes.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please address the open review feedback, refresh the branch if needed, and use the pr-finisher skill before handing back.

Open review threads (newest reviewer feedback first):

No failed checks were reported in the compact candidate set for this run.
Branch update was requested by sous-chef in run https://github.com/github/gh-aw/actions/runs/31500985584.

Generated by 👨🍳 PR Sous Chef
Comment /souschef to run again

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

Copilot AI and others added 3 commits August 11, 2026 14:42
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
…lidation-extension

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

Copilot AI commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please address the open review feedback, refresh the branch if needed, and use the pr-finisher skill before handing back.

Open review threads (newest reviewer feedback first):...

Addressed the four open review findings in dfa815c and refreshed the branch from main in 7dea1f6. Focused tests and the final local validation gate pass.

Copilot AI requested a review from gh-aw-bot August 11, 2026 14:50
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please address the open review feedback, resolve any addressed threads that remain open, refresh the branch if needed, and use the pr-finisher skill before handing back.

Open review threads (newest reviewer feedback first):

No failed checks were reported in the compact candidate set for this run.
Branch update was requested by sous-chef in run https://github.com/github/gh-aw/actions/runs/31505952002.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 6.3 AIC · ⌖ 7.9 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 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please address the open review feedback, resolve any addressed threads that remain open, refresh the branch if needed, and use the pr-finisher skill before handing back.

Open review threads ...

Refreshed the branch from main in ae07f1a. The four cited validation findings were already addressed in dfa815c; focused and final local validation pass.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot rename timeout to timeout-minutes to match other front matter fields

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot rename timeout to timeout-minutes to match other front matter fields

Renamed the public field to validation.timeout-minutes in dfd4674. It accepts 1–5 minutes and converts to the internal seconds-based runtime timeout.

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage: #52053

  • Category: feature
  • Risk: high
  • Priority score: 43/100 (impact 20/50, urgency 8/30, quality 15/20) → medium
  • Recommended action: defer

Automated triage — see labels for machine-readable classification.

Generated by 🔧 PR Triage Agent · auto · 45 AIC · ⌖ 2.09 AIC · ⊞ 7.8K ·

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