Skip to content

fix(repository-credentials): name an App key that goes bad after startup - #3269

Merged
freeqaz merged 2 commits into
mainfrom
fix-appkey-runtime-log
Oct 23, 2026
Merged

freeqaz merged 2 commits into
mainfrom
fix-appkey-runtime-log

Conversation

@freeqaz

@freeqaz freeqaz commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Problem

#3258 made the worker refuse a prepared-git App key that cannot sign before it reports ready, with PREPARED_GITHUB_APP_KEY_INVALID and a fixed reason. If the key goes bad while the worker runs (for example a rotated Secret with an unusable key), maintenance still logged only PREPARED_GITHUB_MAINTENANCE_FAILED, so the operator could not tell a bad key from any other failed pass. The production startup flow also did not mention the startup refusal (a P3 review note on #3258).

Change

  • TokenService.ownFamilies passes the failed pass's error to failed(error).
  • The prepared Git owner reports a PreparedGitHubAppKeyError from maintenance as PREPARED_GITHUB_APP_KEY_INVALID with its fixed reason, which the worker logs as worker.error. Other failures still report PREPARED_GITHUB_MAINTENANCE_FAILED. No key bytes or path are logged.
  • docs/flows/production-startup.md says the worker reads the App key at startup and exits before readiness when it cannot sign. To stay under the word cap, it drops a debugging bullet that repeated the occ installation get ID check from step 5 and tightens two sentences.
  • The team runbook describes the runtime log line.

Verification

  • New case in tests/integration/postgres-prepared-github-git-use.test.mjs: starts an owner with a valid key, replaces the key with a public key, runs the real maintenance loop and asserts the report is PREPARED_GITHUB_APP_KEY_INVALID / app_key_unparsable with no issuance. It fails on main (PREPARED_GITHUB_MAINTENANCE_FAILED with no reason) and passes 10/10 at 2 CPUs. The whole file passes (18/18), as does postgres-prepared-token-service.test.ts.
  • tsc --build, eslint and prettier are clean on touched files. production-startup.md is at 2487 words (was 2488).

Risks

Low. The only behavior change is the code and reason logged for one maintenance failure class. Alerts that match PREPARED_GITHUB_MAINTENANCE_FAILED will no longer fire for a bad App key. They should match PREPARED_GITHUB_APP_KEY_INVALID, which startup already logs.

The prepared Git owner's maintenance loop reported every failure as
PREPARED_GITHUB_MAINTENANCE_FAILED. A rotated Secret with a key that cannot
sign now logs worker.error with PREPARED_GITHUB_APP_KEY_INVALID and the
same fixed reason as the startup refusal, never key bytes or the path.
TokenService.ownFamilies passes the pass's error to failed().

Docs: the production startup flow says the worker reads the App key at
startup and exits before readiness; the runbook describes the runtime log.
Trimmed equal words from the startup flow to stay under the cap.
@freeqaz
freeqaz requested a review from a team as a code owner October 23, 2026 03:51
@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

Internal review nits: keep the test key out of the socket directory helper,
note that the 60 s test timeout bounds the wait, tell owners never to log
the error passed to failed(), and give the 5 s retry interval in the
runbook.
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reports a fixed App-key error code and reason when repository credential maintenance encounters an unusable key after startup.

Example: After worker startup, the mounted RSA private key is replaced with an RSA public key.

  • Before: Maintenance reports PREPARED_GITHUB_MAINTENANCE_FAILED without a reason.
  • After: Maintenance reports PREPARED_GITHUB_APP_KEY_INVALID with reason app_key_unparsable and continues retrying.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful repair with meaningful integration coverage and no findings; behavioral evidence remains at the in-process owner boundary.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary contributor proof gate; supplied validation describes the real maintenance owner with PostgreSQL and a synthetic HTTPS issuer, without shipped-worker runtime evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Operators cannot distinguish an unusable rotated App key from other repository maintenance failures.
Reason: The maintainer-authored change completes an explicitly deferred diagnostic repair without adding configuration or changing credential authority.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses a current diagnostic gap with a focused change, and no actionable correctness or security findings remain.

Priority: P2
Reviewed head: 3cf497d14c2b6bfaa23c2417a90ceb70d94a02e5

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The regression exercises owner reporting rather than launching worker.mjs and observing its emitted worker.error log.
Agent review details

How this fits together

The controller worker's prepared Git owner reloads its mounted App key during maintenance; TokenService schedules passes and forwards failures to the owner, whose fixed diagnostics enter worker logging.

flowchart TB
  A[Worker maintenance] --> B[TokenService pass]
  B --> C[Prepared Git owner]
  C --> D[Read mounted App key]
  D --> E[Typed key refusal]
  E --> F[Fixed code and reason]
  F --> G[Worker error log]
Loading

Technical review

Best possible solution:

Retain error classification in the existing prepared Git owner and preserve generic reporting for unrelated maintenance failures.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes that a runtime key-reading error reaches a callback that discards its classification; the author reports a base-failing, head-passing regression, which this read-only review did not execute.

Is this the best way to solve the issue?

Forwarding the exception to the existing owner is the smallest complete repair and leaves scheduling, key restrictions, issuance, and authorization unchanged.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against da921f0dd4b0.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Free Wortley: Raw commit 3850356 adds apps/controller/src/backends/repository-credentials/prepared-git-owner.ts:146 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 385035667cec; files: apps/controller/src/backends/repository-credentials/prepared-git-owner.ts)

Labels

Label changes:

  • add P2: The change improves diagnosis of an operator-configured repository failure with limited blast radius.
  • add merge-risk: 🚨 compatibility: Existing alerts matching only the generic maintenance code will miss this failure class; the maintainer author explicitly accepts the switch to the existing App-key diagnostic.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The change improves diagnosis of an operator-configured repository failure with limited blast radius.
  • merge-risk: 🚨 compatibility: Existing alerts matching only the generic maintenance code will miss this failure class; the maintainer author explicitly accepts the switch to the existing App-key diagnostic.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 23, 2026, 12:07 AM ET / 04:07 UTC.

@freeqaz
freeqaz merged commit 38ecfca into main Oct 23, 2026
76 checks passed
@freeqaz
freeqaz deleted the fix-appkey-runtime-log branch October 23, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant