Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address daily AIC review cleanup
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
  • Loading branch information
Copilot and pelikhan authored Sep 23, 2026
commit e0d0a95b5e3105935f4927b5740a78d7fb43aa5b
5 changes: 3 additions & 2 deletions actions/setup/js/check_daily_aic_workflow_guardrail.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const INTEGER_FORMATTER = new Intl.NumberFormat("en-US");
const MAX_LEGACY_AGENT_LOG_BYTES = 10 * 1024 * 1024;
const ENGINE_HARNESS_MARKER = /\[[^\]\r\n]+-harness\]/i;
const AWF_STARTUP_FAILURE_MARKER = /Fatal error:|Process exiting with code:|Refusing to use symlink as bind mountpoint|mcp gateway[^\r\n]{0,80}(?:startup failed|failed to start|startup error)/i;
const REPO_MEMORY_BACKEND = "repo-memory";

/**
* @returns {Promise<any>}
Expand Down Expand Up @@ -650,7 +651,7 @@ async function main(options = {}) {

const token = process.env.GH_AW_GITHUB_TOKEN || process.env.GITHUB_TOKEN || process.env.GH_TOKEN || "";
const backend = dailyAICBackend();
if (!token && backend !== "repo-memory") {
if (!token && backend !== REPO_MEMORY_BACKEND) {
const message = "Daily workflow AI Credits are unknown: no artifact lookup token.";
core.setOutput("daily_ai_credits_guardrail_status", "structural_error");
core.setOutput("daily_ai_credits_guardrail_error", message);
Expand All @@ -664,7 +665,7 @@ async function main(options = {}) {
const budget = createAPIBudget();
const workflowName = process.env.GH_AW_WORKFLOW_NAME || process.env.GH_AW_WORKFLOW_ID || "workflow";
let actorLogin = process.env.GITHUB_TRIGGERING_ACTOR || process.env.GITHUB_ACTOR || "";
if (backend === "repo-memory") {
if (backend === REPO_MEMORY_BACKEND) {
const repository = `${context.repo.owner}/${context.repo.repo}`;
const countedRuns = readLedgerEntries({
repoMemoryDir: options.repoMemoryDir || process.env.GH_AW_DAILY_AIC_REPO_MEMORY_DIR,
Expand Down
15 changes: 11 additions & 4 deletions pkg/workflow/compiler_activation_daily_aic.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (c *Compiler) buildActivationDailyAICGuardrailStep(data *WorkflowData) []st
steps = append(steps, fmt.Sprintf(" %s: %q\n", maxDailyAICBackendEnvVar, data.MaxDailyAICBackend))
}
if entry, ok := dailyAICRepoMemoryEntry(data); ok {
steps = append(steps, fmt.Sprintf(" GH_AW_DAILY_AIC_REPO_MEMORY_DIR: %s%s\n", constants.TmpRepoMemoryDir, entry.ID))
steps = append(steps, fmt.Sprintf(" GH_AW_DAILY_AIC_REPO_MEMORY_DIR: %s\n", dailyAICRepoMemoryDir(entry)))
}
steps = append(steps, fmt.Sprintf(" GH_AW_MAX_AI_CREDITS: %s\n", dailyAICMaxCreditsEnvValue(data)))
steps = append(steps, " with:\n")
Expand Down Expand Up @@ -184,6 +184,9 @@ func (c *Compiler) buildDailyAICScanObservationRestoreStep(data *WorkflowData) [
}
}

// dailyAICRepoMemoryEntry selects the repo-memory ledger for the repo-memory
// daily AIC backend. It prefers the memory with id "default" and otherwise
// falls back to the first configured memory.
func dailyAICRepoMemoryEntry(data *WorkflowData) (RepoMemoryEntry, bool) {
if data == nil || data.MaxDailyAICBackend != maxDailyAICBackendRepoMemory || data.RepoMemoryConfig == nil {
return RepoMemoryEntry{}, false
Expand All @@ -193,14 +196,18 @@ func dailyAICRepoMemoryEntry(data *WorkflowData) (RepoMemoryEntry, bool) {
return memory, true
}
}
if len(data.RepoMemoryConfig.Memories) > 0 {
for _, memory := range data.RepoMemoryConfig.Memories {
for index, memory := range data.RepoMemoryConfig.Memories {
if index == 0 {
return memory, true
}
}
return RepoMemoryEntry{}, false
}

func dailyAICRepoMemoryDir(memory RepoMemoryEntry) string {
return constants.TmpRepoMemoryDir + memory.ID
}

func buildDailyAICRepoMemoryCloneStep(memory RepoMemoryEntry) []string {
targetRepo := memory.TargetRepo
if targetRepo == "" {
Expand All @@ -213,7 +220,7 @@ func buildDailyAICRepoMemoryCloneStep(memory RepoMemoryEntry) []string {
if memory.Wiki {
memoryLabel = "wiki-memory"
}
memoryDir := constants.TmpRepoMemoryDir + memory.ID
memoryDir := dailyAICRepoMemoryDir(memory)
return []string{
fmt.Sprintf(" - name: Clone daily AIC %s ledger (%s)\n", memoryLabel, memory.ID),
fmt.Sprintf(" if: %s\n", maxDailyAICreditsConfiguredIfExpr),
Expand Down
4 changes: 1 addition & 3 deletions pkg/workflow/compiler_daily_aic_repo_memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package workflow
import (
"fmt"
"strings"

"github.com/github/gh-aw/pkg/constants"
)

func (c *Compiler) generateDailyAICRepoMemoryLedgerStep(builder *strings.Builder, data *WorkflowData) {
Expand All @@ -18,7 +16,7 @@ func (c *Compiler) generateDailyAICRepoMemoryLedgerStep(builder *strings.Builder
fmt.Fprintf(builder, " uses: %s\n", getCachedActionPin("actions/github-script", data))
builder.WriteString(" env:\n")
fmt.Fprintf(builder, " GH_AW_WORKFLOW_ID: %q\n", data.WorkflowID)
fmt.Fprintf(builder, " GH_AW_DAILY_AIC_REPO_MEMORY_DIR: %s%s\n", constants.TmpRepoMemoryDir, entry.ID)
fmt.Fprintf(builder, " GH_AW_DAILY_AIC_REPO_MEMORY_DIR: %s\n", dailyAICRepoMemoryDir(entry))
builder.WriteString(" GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n")
builder.WriteString(" with:\n")
builder.WriteString(" script: |\n")
Expand Down
Loading