Skip to content

Fix secure bootstrap for repo-memory daily AIC ledgers - #70358

Merged
pelikhan merged 5 commits into
mainfrom
pelikhan-jubilant-tribble
Oct 19, 2026
Merged

pelikhan merged 5 commits into
mainfrom
pelikhan-jubilant-tribble

Conversation

@pelikhan

Copy link
Copy Markdown
Collaborator

Summary

Fix the activation deadlock seen in Daily Code Metrics run 39304180678, where the memory branch was missing, the local orphan remained untrusted, and activation prevented the downstream writer from creating the branch.

  • Keep backend: repo-memory. A successful clone step that explicitly confirms branch absence now authorizes artifact-backed accounting, not trust in the orphan or an assumption of zero usage.
  • Record repository/workflow-scoped coverage metadata in the trusted downstream ledger writer. New and legacy ledgers use authoritative artifact accounting until coverage is at least 24 hours old, so recent usage is not erased during bootstrap.
  • Preserve daily limits, per-run estimates, trust checks, and fail-closed API/quota handling. Do not enable insecure overrides or warning mode, add permissions, or change workflow settings.
  • Regenerate the three affected workflow locks; add regression coverage, documentation, and a patch changeset.

Existing workflows must be recompiled after upgrading to receive the confirmed-missing-branch signal. Existing mature-ledger completeness limitations are unchanged.

Validation

  • Focused JavaScript backend suites, including the original missing-branch/skipped-AI-jobs case, historical spending, threshold equality, missing credentials, 403/429 failures, coverage migration, and the 24-hour boundary.
  • JavaScript typecheck, formatting and lint; targeted Go compiler regression tests.
  • make agent-report-progress passed using installed Bash 5, including impacted tests and drift validation across all 344 workflows.

No workflow dispatch/rerun or repository settings change was performed. Production recovery remains to be observed after deployment.

Use authoritative artifact accounting for confirmed-missing branches and while trusted ledger coverage matures. Preserve daily thresholds and fail-closed trust and quota checks.

Co-authored-by: Copilot App <[email protected]>
@pelikhan
pelikhan marked this pull request as ready for review October 19, 2026 20:15
Copilot AI max review requested due to automatic review settings October 19, 2026 20:15
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Oct 19, 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 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · gpt56 · 7.13 AIC · ⌖ 5.47 AIC · ⊞ 14.7K · ◷

Generated by Ponytail Reviewer for #70358

@github-actions

github-actions Bot commented Oct 19, 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.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · opus55 · 10.1 AIC · ⌖ 31.8 AIC · ◇ 12.7 AIC · ⊞ 1.9K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · sonnet50 · 14.7 AIC · ⌖ 15.1 AIC · ◇ 4.45 AIC · ⊞ 12.6K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@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.

Verdict: approve

No actionable blocking issues found in the changed lines. The bootstrap path is fail-closed on untrusted clone outcomes, requires artifact access while coverage warms, and preserves mature trusted-ledger behavior. Static review only; repository tests were not executed.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · 3.49 AIC · ⌖ 0.534 AIC · ⊞ 1.6K
Comment /review 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 /diagnosing-bugs and /tdd (pr-triage: bug_fix). This fixes a real production deadlock (missing memory branch + untrusted orphan blocking the ledger writer) with a well-reasoned fix: artifact-backed bootstrap only fires after the clone step confirms the branch is absent, and a repository/workflow-scoped 24h coverage marker prevents a fresh ledger from masking recent spend.

📋 Key Themes & Highlights

Root cause addressed, not just symptom

The original deadlock was: no branch → untrusted ledger → guardrail fails closed → writer never runs → branch never gets created. The fix distinguishes "untrusted because corrupted/stale" from "confirmed absent" via the new GH_AW_DAILY_AIC_REPO_MEMORY_BRANCH_MISSING signal, which is only set true when the clone step's outcome == 'success' and cloned == 'false' — so transport/auth failures in clone_repo_memory_branch.sh still fail closed. That distinction is the crux of the fix and is correctly wired through pkg/workflow/compiler_activation_daily_aic.go into all three lock files.

Regression coverage is strong

daily_aic_spec_conformance.test.cjs adds a parametrized test across missing/legacy/warming/future/wrong_identity/malformed coverage states, plus dedicated tests for: 403/429 fail-closed, no-token-during-bootstrap, daily limit still enforced during bootstrap, and the specific skipped-AI-jobs scenario from the original incident. daily_aic_repo_memory_ledger.test.cjs covers coverage-path identity isolation and unreadable-metadata-surfaces-as-error (rather than silently falling back to ledger-only accounting) — exactly the kind of failure-path instrumentation /diagnosing-bugs asks for.

Fail-closed semantics preserved

The untrusted-orphan case (ledger present but branch unconfirmed) still requires artifact accounting even with mature-looking coverage metadata, since the coverage marker is only trusted when trustedLedger is true, not merely because a coverage file exists on disk.

Minor nit (non-blocking)

Left one inline comment on daily_aic_repo_memory_ledger.cjs about initializeLedgerCoverage doing a full read+parse purely to check existence on every ledger append — harmless today, just flagging so it doesn't get "simplified" into a raw existence check that skips identity validation.

Positive highlights

  • ✅ Spec and docs (ai-credits-specification.md, cost-management.md) updated in the same PR to describe the new bootstrap/coverage contract
  • ✅ No new permissions, no insecure-override defaults, no workflow settings changes — scope stayed tight
  • ✅ Coverage identity hashing (sha256 of repository + workflowId) correctly isolates per-repo/per-workflow state, with a test asserting path separation

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

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

Persistence filters can discard coverage metadata or usage shards, preventing reliable transition to ledger accounting.

1 open issue
What changed in this PR

Enables secure bootstrap for repo-memory daily AI Credits accounting without treating a missing ledger as zero usage.

Changes:

  • Uses artifact accounting until trusted ledger coverage reaches 24 hours.
  • Adds bootstrap, coverage migration, and compiler regression tests.
  • Updates documentation, three workflow locks, and release notes.
File Description
pkg/​workflow/​daily_aic_workflow_guardrail_test.go Verifies the missing-branch signal.
pkg/​workflow/​compiler_activation_daily_aic.go Emits the confirmed-missing-branch signal.
docs/​src/​content/​docs/​specs/​ai-credits-specification.md Defines bootstrap and coverage requirements.
docs/​src/​content/​docs/​reference/​cost-management.md Documents bootstrap and recompilation.
actions/​setup/​js/​daily_aic_spec_conformance.test.cjs Covers bootstrap decisions and failures.
actions/​setup/​js/​daily_aic_scan.test.cjs Supplies mature coverage for ledger tests.
actions/​setup/​js/​daily_aic_repo_memory_ledger.test.cjs Tests coverage identity and persistence.
actions/​setup/​js/​daily_aic_repo_memory_ledger.cjs Writes and validates coverage metadata.
actions/​setup/​js/​check_daily_aic_workflow_guardrail.test.cjs Tests mature-ledger acceptance.
actions/​setup/​js/​check_daily_aic_workflow_guardrail.cjs Selects artifact or ledger accounting.
.github/​workflows/​daily-community-attribution.lock.yml Wires the bootstrap signal.
.github/​workflows/​daily-code-metrics.lock.yml Wires the bootstrap signal.
.github/​workflows/​daily-cli-performance.lock.yml Wires the bootstrap signal.
.changeset/​patch-repo-memory-aic-bootstrap.md Adds a patch release note.

Review effort: Max

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/daily_aic_repo_memory_ledger.cjs:148): [/codebase-design] Minor: initializeLedgerCoverage calls readLedgerCoverageStart (which does a fs.readFileSync + JSON parse) on every write just to check existence, then appendCurrentRunLedgerEntry calls it again unconditionally per run. Not a bug, just an extra disk read per run that could be a cheap fs.existsSync guard if this becomes hot-path sensitive. - Fix secure bootstrap for repo-memory daily AIC ledgers #70358 (comment)
  3. Review (actions/setup/js/daily_aic_repo_memory_ledger.cjs:31): The new coverage marker and the usage shards pass through the user-configurable persistence filters in push_repo_memory.cjs:718. The root-only globs in Daily Code Metrics and Daily CLI Performance reject both nested files, so these workflows never leave artifact-backed bootstrap. A .jsonl-only extension list also drops the marker. - Fix secure bootstrap for repo-memory daily AIC ledgers #70358 (comment)

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: 7d4642b
Sous-chef work: 570f4d6b7f04caee5bf6547e8d3a618f9f804b602dfb749121ec0c1e715afff7 cc1fc2aa3350d8d52a61b45114fb0e6379b747b93f80df8cf0bfe0987722808f
Sous-chef state: 0165f6216cd9ecb1eb5b71e6eb7f816233f683e368e7bba2fda4e4dcb5a347be

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · 11.4 AIC · ⌖ 6.82 AIC · ⊞ 1.1K · ◷
Comment /souschef to run again

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Original comment: Accepted as informational; the linked code quality review found no actionable blocking issue and explicitly says it was static-only. No code change is needed for this notice, and it is not being treated as evidence that tests passed.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Original comment: Accepted as informational; the linked skills review approves the change, and its minor inline nit is already addressed and resolved in the separate review thread. This completion notice requires no additional code change.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Original comment: Accepted as a status report only; it contains no actionable recommendation, so no code change follows from it. The reported_no_action outcome is not being treated as proof of completed review or successful publication.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Original comment: Accepted as a status report only; no ADR draft or requested design change is supplied, so no ADR or tooling change is warranted. The completion status alone does not establish that all intended work succeeded.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Original comment: Accepted as informational; no specific test defect or requested coverage change is provided, so this notice requires no additional test change. Its reported_no_action outcome is not a substitute for focused tests and the final local validation gate.

Gate the selected ledger memory's filter exemption on successful compiler-owned sanitation. Preserve restrictive filters for ordinary memories and cover trusted persistence and forged-ledger removal.

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

Copy link
Copy Markdown
Collaborator Author

Original comment: Merged the latest fetched main (e659ac3) and pushed the review batch in c01a2f6. Both inline findings are answered and resolved; all five informational notices received individual responses.

The persistence exception now applies only to the selected trusted daily-AIC writer after successful removal of agent-supplied ledger files. Ordinary memories retain their filters, and existing size/count/patch limits are unchanged. Added restrictive-filter persistence and forged-ledger sanitation regressions.

Local validation passed: focused Go regressions, 373 JavaScript tests, formatting/lint/custom analyzers, and the final pre-PR gate with all 344 workflow locks in sync. CI on the new head has not been evaluated. No workflow dispatches or CI reruns were requested, no insecure override or budget relaxation was enabled, and the PR remains open and ready for review.

@pelikhan
pelikhan merged commit b68bd31 into main Oct 19, 2026
56 checks passed
@pelikhan
pelikhan deleted the pelikhan-jubilant-tribble branch October 19, 2026 23:04
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.92.6

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.

4 participants