> Agent-ready spec from Diff of the Day (2026-11-30, idea 4). Give this file to your coding agent (Claude Code, Codex, Cursor) and ask it to build the P0 requirements first.

# Spec: Key and certificate inventory with a rotation runbook

## Problem Statement
Rumours of a break in RSA-2048 spread this weekend without any published result. They still raised a question that most small teams cannot answer: which keys and certificates does our system depend on, which algorithms do they use, and how long would it take to replace them? Without an inventory, a real incident or a routine expiry turns into a search under pressure.

## Goals
- Produce one inventory file that lists every key and certificate reference found in the repository and its deployment configuration.
- For each entry, record the algorithm, the key size where it can be read, the owner and the expiry date.
- Write and test a rotation runbook for the three entries that matter most.

## Non-Goals
- Migrating to post-quantum algorithms: the inventory comes first.
- Scanning other people's systems: only repositories and environments you own.
- Storing key material: the tool records where a key is, never the key.

## User Stories
- As an engineer, I want one list of every key and certificate so that I know what a rotation touches.
- As an on-call engineer, I want written and tested rotation steps so that I do not improvise during an incident.
- As a team lead, I want expiry dates in one place so that nothing expires by surprise.
- Edge case: as an engineer, I want a private key found in the repository reported as a finding with its path, and its content never printed.

## Requirements
### P0 (must have)
- **Scanner**
  - [ ] Finds certificate and key files, references to secret stores, and algorithm names in code and configuration
  - [ ] Never prints or copies the content of a private key; it reports the path and the type only
- **Inventory file**
  - [ ] inventory.md has one row per entry with the location, algorithm, key size, owner and expiry
  - [ ] Entries whose details cannot be read are marked unknown, not guessed
- **Runbook for three entries**
  - [ ] runbook.md has numbered rotation steps for the three most important entries
  - [ ] One rotation is executed in a test environment and the time it took is recorded
### P1 (nice to have)
- **Expiry warning**
  - [ ] A script lists entries that expire within 60 days
- **Weak-parameter flags**
  - [ ] RSA keys under 2048 bits and deprecated hash algorithms are flagged
### P2 (later)
- A scheduled job that refreshes the inventory.
- A post-quantum migration plan per entry.

## Success Metrics
- Leading: the inventory covers every deployment environment of the project.
- Leading: one rotation is completed in test, with a recorded duration.
- Lagging: the next certificate renewal follows the runbook with no surprises.

## Open Questions
- Which environments are in scope? (you)
- Who owns keys that are managed by a cloud provider? (you, non-blocking)

## Timeline
One evening for P0 on one repository.

## Agent Instructions
- **Suggested stack**: Python 3.12 with the cryptography package to read certificates, or Go with the standard library.
- **Build order**: file and configuration scanner with tests on sample files, then the inventory writer, then the runbook, then one timed rotation in test.
- **Safety**: read-only on every system; never print, copy or commit key material; run the rotation only in a test environment; ask before any step that needs credentials.
- **Done when**: inventory.md and runbook.md exist, no key content appears in any output, and one test rotation has a recorded time.

## Sources
- Cryptography Incident Review Group: https://cirg.org/
