Skip to content

Split general workflow patches into ordered domain modules - #11544

Merged
lpcox merged 16 commits into
mainfrom
copilot/refactor-split-patch-modules
Nov 13, 2026
Merged

lpcox merged 16 commits into
mainfrom
copilot/refactor-split-patch-modules

Conversation

Copilot AI commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

applyGeneralWorkflowPatches mixed order-dependent transforms in a 1,090-line function, obscuring credential isolation and cache-memory hardening.

  • Ordered pipeline: Reduce the entry point to 68 lines, retaining interleaved stages and log-message order.
  • Domain ownership: Extract network/install, session-state, engine lifecycle, credentials, cache-memory, and concurrency patches, plus admission, Azure smoke, and enclave handling. Move regexes and sentinels alongside their domains.
  • Compatibility: Preserve public exports and shared regex identities through compatibility re-exports; retain fail-fast guards.
  • Output equivalence: Preserve byte-identical output across all 74 existing locks and three smoke workflows compiled before and after the split. No generated locks change.

Copilot AI changed the title [WIP] Refactor apply-general-workflow-patches.ts into per-domain modules Split general workflow patches into ordered domain modules Nov 13, 2026
Copilot AI requested a review from lpcox November 13, 2026 15:53
@lpcox
lpcox marked this pull request as ready for review November 13, 2026 15:53
Copilot AI adaptive review requested due to automatic review settings November 13, 2026 15:53
Comment thread scripts/ci/workflow-patches/enclave.ts Resolved
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

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

The extraction removes rationale comments for the Azure credential-exclusion workaround and diagnosis-maintenance cache retention, leaving these intentional exceptions unexplained.

2 open issues
What changed in this PR

Refactors AWF’s compiled-workflow postprocessor into an ordered pipeline and domain modules, addressing #11540 while preserving the existing public interfaces.

Changes:

  • Extracts transforms, patterns, and sentinels into focused modules without changing generated locks.
  • Preserves interleaved processing order and compatibility exports.
  • Adds tests for domain behavior, safeguards, idempotency, log order, and shared regex identity.
File Description
scripts/​ci/​workflow-step-builders.ts Imports the engine sentinel from its owning module.
scripts/​ci/​workflow-patches/​workflow-patches.test.ts Adds domain and pipeline compatibility tests.
scripts/​ci/​workflow-patches/​types.ts Defines shared transform and context interfaces.
scripts/​ci/​workflow-patches/​session-state.ts Owns session-state injection and log-path normalization.
scripts/​ci/​workflow-patches/​network-and-install.ts Owns feed, installer, release-selection, and image transforms.
scripts/​ci/​workflow-patches/​network-and-install-patterns.ts Houses installation and image-related patterns.
scripts/​ci/​workflow-patches/​engine-lifecycle.ts Owns engine installation, copy gating, tools, and model transforms.
scripts/​ci/​workflow-patches/​engine-lifecycle-patterns.ts Houses engine-specific patterns and helpers.
scripts/​ci/​workflow-patches/​enclave.ts Extracts gateway, readiness, metadata, and diagnostic transforms.
scripts/​ci/​workflow-patches/​credentials.ts Extracts credential exclusions and recovery-root restrictions.
scripts/​ci/​workflow-patches/​concurrency.ts Owns per-issue conclusion concurrency scoping.
scripts/​ci/​workflow-patches/​cache-memory.ts Extracts cache hardening and persistence policies.
scripts/​ci/​workflow-patches/​cache-memory-patterns.ts Houses cache-memory patterns and sentinels.
scripts/​ci/​workflow-patches/​azure-smoke.ts Extracts Azure smoke pricing and tool restrictions.
scripts/​ci/​workflow-patches/​admission.ts Extracts disabled-admission output declarations.
scripts/​ci/​workflow-patch-patterns.ts Re-exports moved symbols for compatibility.
scripts/​ci/​apply-general-workflow-patches.ts Replaces the monolithic function with a 68-line ordered pipeline.

Review effort: Max (dynamic)

messages.push(` 'Scan cache-memory for instruction-injection' step already present (new version)`);
}

if (workflowFile !== undefined && diagnosisMaintenanceCacheWorkflowLockFiles.has(workflowFile)) {
return { content, messages };
}

export function excludeAzureCredentials(content: string, { workflowPath }: PatchContext): TransformResult {
@lpcox lpcox closed this Nov 13, 2026
@lpcox lpcox reopened this Nov 13, 2026
@lpcox

lpcox commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

@copilot address all review feedback

Copilot AI commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address all review feedback

Addressed the review feedback in commit 5035d5c: preserved and regression-tested the GH_TOKEN fail-closed guard, restored both rationale comments, and completed regex metacharacter escaping. Targeted Jest could not run because dependencies were unavailable and the configured package-feed hostname did not resolve; CodeQL skipped analysis due to database size.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@lpcox

lpcox commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Copilot AI commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix the failing unit tests https://github.com/github/gh-aw-firewall/actions/runs/43466295240/job/132026675073?pr=11544

Fixed the failing fixture in c7fe2cb by including the required primary-agent exclusion anchor and asserting the GH_TOKEN exclusion. I couldn't run Jest locally because dependencies are absent and the package-feed hostname failed DNS resolution.

Comment thread scripts/ci/workflow-patches/enclave.ts Resolved
lpcox and others added 2 commits November 13, 2026 09:14
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
lpcox and others added 2 commits November 13, 2026 09:42
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Cover explicit session-state opt-in and fail-closed Azure exclusions, preserve the session-state facade export, and tolerate insignificant command whitespace.

Co-authored-by: Copilot App <[email protected]>

export function hardenCacheMemory(content: string, { workflowFile }: PatchContext): TransformResult {
const messages: string[] = [];
const scanInjectionStep = buildScanInjectionStep(HARDENED_INJECTION_PATTERN);
…ort, function or class'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@lpcox

lpcox commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

@copilot make sure that all review feedback is addressed and that 'npm test' runs without any failures


// Case-insensitive and tolerant of leading whitespace / common punctuation prefixes.
// This is used when (re)injecting the scan step to reduce prompt-injection bypasses.
const HARDENED_INJECTION_PATTERN = String.raw`(?i).*(?:^|[\s\-\*\>\#\|:;.,\(\)\[\]\{\}"'])(system|assistant|developer|user)\s*:.*`;
lpcox and others added 2 commits November 13, 2026 10:16
…ort, function or class'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 93.89% 93.92% 📈 +0.03%
Statements 92.45% 92.48% 📈 +0.03%
Functions 93.13% 93.14% 📈 +0.01%
Branches 86.86% 86.87% 📈 +0.01%
✨ New Files (1 files)
  • src/cloud-hypervisor/host-enclave-executor.test-utils.ts: 98.6% lines

Coverage comparison generated by scripts/ci/compare-coverage.ts

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

Copilot AI commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot make sure that all review feedback is addressed and that 'npm test' runs without any failures

Fixed the scanner hardening gap and added regression coverage for insertion and upgrade in ad325b8. Root Unit Tests passed: 587 suites and 13,264 tests (73 skipped).

@lpcox
lpcox merged commit 13df8d5 into main Nov 13, 2026
36 of 37 checks passed
@lpcox
lpcox deleted the copilot/refactor-split-patch-modules branch November 13, 2026 20:27
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.

[Refactoring] Split scripts/ci/apply-general-workflow-patches.ts into per-domain patch modules

4 participants