Skip to content

Consolidate ledger compaction into two Agentic Maintenance jobs - #64709

Merged
pelikhan merged 4 commits into
mainfrom
copilot/update-ledger-compaction-plan
Oct 1, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/update-ledger-compaction-plan

Conversation

Copilot AI commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Agentic Maintenance currently creates a plan job and an apply job for every ledger. This change consolidates them into one plan job and one apply job.

  • Planning: Run ledger-specific planning steps in a read-only job and upload created plans as one artifact.
  • Application: Run only the apply steps with created plans in a separate write-enabled job; each plan retains its per-ledger validation.
  • Generated workflow: Update the Agentic Maintenance workflow, tests, and compaction documentation to reflect the two-job structure.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Consolidate ledger compaction into two agentic maintenance jobs Consolidate ledger compaction into two Agentic Maintenance jobs Oct 1, 2026
Copilot AI requested a review from pelikhan October 1, 2026 06:48
@pelikhan
pelikhan marked this pull request as ready for review October 1, 2026 11:13
Copilot AI balanced review requested due to automatic review settings October 1, 2026 11:13
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

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

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

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

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

Unable to emit PR review writes from this environment after safeoutputs write attempts were denied at the shell boundary while reviewing PR #64709.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

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.

Copilot review overview

🟡 Changes recommended

Shared failure and concurrency behavior can skip valid plans, while case-sensitive ledger names can collide on supported runners.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Consolidates per-ledger compaction into one planning job and one trusted application job.

Changes:

  • Generates per-ledger steps and plan files within two shared jobs.
  • Updates tests, documentation, and generated workflow YAML.
  • Preserves read/write permission separation and plan validation.
File Description
pkg/​workflow/​maintenance_workflow_ledger_compaction.go Generates consolidated compaction jobs.
pkg/​workflow/​maintenance_workflow_ledger_compaction_test.go Tests the two-job structure.
docs/​src/​content/​docs/​experimental/​ledger-compaction.md Documents consolidated execution.
.github/​workflows/​agentics-maintenance.yml Applies the generated workflow changes.

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

group: gh-aw-ledger-compaction-${{ github.repository }}-` + ledger.Name + `
cancel-in-progress: false
`,
planFile := path.Join(maintenanceLedgerCompactionPlanDir, "plan-"+ledger.Name+".json")
Comment on lines +152 to +154
concurrency:
group: gh-aw-ledger-compaction-${{ github.repository }}
cancel-in-progress: false
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor
🏗️ ADR Required - draft added for PR #64709

I added a draft ADR at docs/adr/64709-consolidate-ledger-compaction-jobs.md because this PR exceeds the design gate threshold for business-logic changes and does not include an existing ADR.

Evidence used

  • adr-prefetch-summary.json: default_business_additions = 122, so ADR enforcement is required.
  • PR description: the change consolidates per-ledger compaction plan/apply jobs into one shared plan job and one shared apply job.
  • Diff and tests: .github/workflows/agentics-maintenance.yml, pkg/workflow/maintenance_workflow_ledger_compaction.go, and pkg/workflow/maintenance_workflow_ledger_compaction_test.go all reflect a move from per-ledger jobs to shared jobs with per-ledger steps and outputs.

Inferred decision

Consolidate ledger compaction orchestration into two repository-wide maintenance jobs while preserving the trust boundary and per-ledger validation through step-level execution and per-ledger plan files.

Next action

Please review and refine the draft ADR, then keep it with this implementation so the architectural change is documented explicitly before merge.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · gpt54 · 24.5 AIC · ⌖ 12.7 AIC · ⊞ 9.9K · ◷
Comment /review to run again

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-10-01T11:17:54.934+00:00
review_event: REQUEST_CHANGES
top_themes:
  - shared plan job loses per-ledger failure isolation
  - shared apply job loses per-ledger failure isolation
  - safeoutputs review-write permission failure blocked publication
files_reviewed:
  - .github/workflows/agentics-maintenance.yml
  - docs/src/content/docs/experimental/ledger-compaction.md
  - pkg/workflow/maintenance_workflow_ledger_compaction.go
  - pkg/workflow/maintenance_workflow_ledger_compaction_test.go
comment_count: 2

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 50.2 AIC · ⌖ 7.07 AIC · ⊞ 19.2K · ◷
Comment /review to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

pr-sous-chef
@copilot this PR still needs forward progress before a maintainer can investigate efficiently.
...

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 12.3 AIC · ⌖ 9.94 AIC · ⊞ 9.4K · ◷
Comment /souschef to run again

@github-actions github-actions Bot 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.

Skills-Based Review 🧠

Applied /codebase-design and /grill-with-docs — this is a clean architectural consolidation (6 job pairs → 2 jobs, per-step conditions instead of per-job), with good test coverage of the new structure and no change to the validated trust boundary (plan job stays read-only/untrusted, apply job stays write/trusted with expected-head-guard revalidation). Submitting as COMMENT since the issues raised are about fault-isolation trade-offs worth a deliberate decision, not correctness bugs.

📋 Key Themes & Highlights

Key Themes

  • Fault isolation changed: consolidating per-ledger jobs into shared jobs means one slow/hanging selection script or one rejected/failed apply for a ledger can now affect sibling ledgers' steps in the same job run — this wasn't true before. Worth either mitigating (timeouts, continue-on-error on apply steps) or explicitly documenting as accepted behavior.
  • Docs: the trust-boundary table nicely reflects the job consolidation but doesn't call out the fault-isolation trade-off.

Positive Highlights

  • ✅ Test coverage was properly updated (TestGenerateMaintenanceWorkflow_LedgerCompaction, case-sensitivity test) to assert the new step-ID-based structure, not just job-count changes.
  • ✅ Per-ledger plan files (plan-<name>.json) in a shared dir avoid the earlier single plan.json collision risk and keep trust/validation logic (validatePlan, expected-head guard) unchanged per ledger.
  • ✅ Concurrency group simplification to repository-wide (gh-aw-ledger-compaction-${{ github.repository }}) is consistent with the new single-job model.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 117.1 AIC · ⌖ 14.6 AIC · ⊞ 10K
Comment /matt to run again

id: plan
uses: ` + job.githubScriptPin + `
for _, job := range jobs {
b.WriteString(` - name: Plan ledger compaction (` + job.ledger + `, untrusted, read-only)

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.

[/codebase-design] Consolidating 6 untrusted plan steps into one job means a single misbehaving/slow selection script (e.g. an infinite loop or hang in one ledger's compaction.script) can block or exhaust the time budget for every other ledger's plan step in the same job run, whereas the previous per-ledger job design isolated that fault.

💡 Suggestion

Consider adding a per-step timeout-minutes (the ledger_compaction.cjs worker already enforces MAX_WORKER_INPUT_BYTES/timeout internally for the script sandbox, but the outer github-script step itself has no bound) so one slow ledger can't starve the others sharing the job, and so the shared job's overall runtime stays predictable as more ledgers are added.

@copilot please address this.

if: ${{ steps.plan.outputs.plan_created == 'true' }}
`)
}
b.WriteString(` - name: Upload ledger compaction plans

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.

[/codebase-design] The single ledger-compaction-plans artifact and single ledger_compaction_apply job mean one ledger's plan being rejected/invalid during apply raises RejectedPlanError via validatePlan/prepareApply per-step, but since each apply step is independent (if: needs...stepID_created) a thrown error in one apply step will still fail the whole job and skip remaining ledger applies for that run (GitHub Actions stops subsequent steps by default unless continue-on-error/if: always() is set).

💡 Suggestion

Add continue-on-error: true to each per-ledger apply step (mirroring the pattern used elsewhere in this codebase, e.g. checkout_step_generator.go's credential-cleanup step), or restructure so a rejected plan for ledger A doesn't prevent ledger B's plan from being applied in the same run. Confirm the intended behavior and document it either way, since this is a change in fault-isolation semantics from the prior per-ledger job design.

@copilot please address this.

concurrency group:
All compaction-enabled ledgers share two maintenance jobs and a repository-wide
compaction concurrency group:

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.

[/grill-with-docs] The trust-boundary table now describes two shared jobs, but doesn't mention the fault-isolation trade-off introduced by consolidation (a hung/slow selection script or an apply failure for one ledger can affect the shared job run for all ledgers). Given this is a security-relevant trust-boundary doc, it's worth being explicit about what changed in the failure/isolation model, not just the job count.

💡 Suggestion

Add a short sentence noting that ledgers now share job-level fault domains (one slow/failing step can block sibling steps in the same job run), so operators know this is a deliberate trade-off for fewer jobs, not an oversight.

@copilot please address this.

@github-actions github-actions Bot 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.

Reviewed with the impeccable harden / audit lens (refactor/cleanup of shared-infra jobs) focused on correctness, reliability, and edge-state handling of the new consolidated plan/apply jobs.

Findings

# Severity File Lines Issue Confidence
1 🟠 HIGH pkg/workflow/maintenance_workflow_ledger_compaction.go 165-179 Per-ledger plan steps now run sequentially inside one shared job with no continue-on-error/if: always(); a single ledger's step throwing (script re-throws on unexpected errors) aborts the job and skips planning/upload/apply for every other ledger in the run, a regression from the prior per-ledger job isolation 8/10

Other observations (non-blocking)

  • The per-ledger apply steps (lines 213-228) have the same sequential-failure characteristic on the trusted side; consider the same guard there for consistency once the plan-side fix lands.
  • Docs (docs/src/content/docs/experimental/ledger-compaction.md) were updated consistently with the new two-job model — good.
  • Tests were updated to match the new job/step shape and assert the shared concurrency group and consolidated artifact name — good coverage of the structural change, but no test currently exercises one ledger's step failing while others succeed.

Requesting changes mainly for item #1, since it silently degrades the ledger-compaction guarantee (every enabled ledger gets a chance to run each maintenance cycle) that the single-job-per-ledger design previously provided.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · copilot · sonnet50 · 119.3 AIC · ⌖ 13.1 AIC · ⊞ 8.1K

@@ -173,37 +176,45 @@ func writeLedgerCompactionPlanJob(b *strings.Builder, opts buildMaintenanceWorkf
const { main } = require('${{ runner.temp }}/gh-aw/actions/ledger_compaction_plan.cjs');
await main();

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.

Missing failure isolation between ledgers sharing this job.

Previously each ledger had its own ledger_compaction_plan_<name> job, so one ledger's failure could not affect any other ledger. Now all ledgers' plan steps run sequentially inside a single ledger_compaction_plan job with no continue-on-error: true / if: always() on each step.

ledger_compaction_plan.cjs.main() re-throws on any unexpected error (see its catch block), which fails the actions/github-script step. By default GitHub Actions skips all subsequent steps in a job once one fails, so a single misbehaving or misconfigured ledger (bad selection script, network error, malformed config) silently prevents planning (and therefore the upload + apply) for every ledger ordered after it in the same run.

Consider adding continue-on-error: true to each per-ledger step (and aggregating failures explicitly), or wrapping the await main() calls so a single ledger's exception cannot abort the whole job.

@copilot please address this.

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

Copilot AI commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

pr-sous-chef
@copilot this PR still needs forward progress before a maintainer can investigate efficiently.
......

Implemented the ledger compaction fixes in b5098cd: plans now use unique indexed filenames, the cross-phase concurrency groups are removed, and per-ledger failures no longer prevent sibling plans or applies from running.

@pelikhan

pelikhan commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

@copilot do not use base64 to encode config. Must be human readable.

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

Copilot AI commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot do not use base64 to encode config. Must be human readable.

Updated ledger compaction configuration to use indented JSON in the workflow environment instead of base64, with the parser and tests updated accordingly. Commit: e1c6a1e.

@pelikhan
pelikhan merged commit 58d82e5 into main Oct 1, 2026
4 of 5 checks passed
@pelikhan
pelikhan deleted the copilot/update-ledger-compaction-plan branch October 1, 2026 12:54
Copilot AI restored the copilot/update-ledger-compaction-plan branch October 1, 2026 12:55
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.90.3

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.

4 participants