ls-wf-openpgp-key-lifecycle · v1.3 · 2026-10-25 · sha256 cadef4130e108676
ls-wf-openpgp-key-lifecycle v1.3A
Immutable. This exact content never changes and is served at /api/v1/blob/cadef4130e108676.
--- name: ls-wf-openpgp-key-lifecycle description: Share, verify, and accept encrypted files with private provenance across carriers; adopt, generate, back up, rotate, revoke, or recover OpenPGP keys using shared local trust. No automatic enrollment or disclosure. metadata: version: "1.3" --- ## Purpose Manage an OpenPGP key throughout its life, or share an encrypted artifact with private provenance across carriers, using `ls.core.openpgp`. Select the operation the user needs; do not run every phase for every request. Installation only makes this workflow available. It does not create keys, contact a provider, resolve a passphrase, or enroll trust. Use the [shared OpenPGP runtime contract](../../docs/OPENPGP_RUNTIME.md) and the [historical design specification](../../docs/AGENTIC_AGENT_Q_BIDIRECTIONAL_BUILD_SPEC.md) and the public [Python API](../../core/openpgp/__init__.py). The functions below are Python APIs, not invented CLI commands. Use the installed LocalSetup Python runtime or the repository's locked uv environment. Keep private key homes and trust databases outside versioned application installations and public workspaces. ## Select identity and authority Identify the owner, publisher and intended full fingerprints through the user's existing authenticated channel. Select a private GnuPG home, private trust-store path, scope, capabilities and `KeyProfile`. A display name, email, short key ID, remote URL or successful decryption does not establish identity. Call `inspect_key()` for an existing public certificate or selected keyring, then `enroll_key()` with the expected full fingerprint, capabilities and profile. Inspect its returned evidence before retaining the new local pin. For persistent owner/publisher authority, `initialize_trust_state()` creates the selected store once; use `load_trust_state()` thereafter. Preserve its store ID and revision for changes. Do not reinitialize a store to get around a failed transition. For interactive certificate enrollment, explicitly bind a `NativeInputContext` to the existing owned native family session and the descriptor from `describe_enrollment_operation()`, then pass it to `enroll_key()`. The primary viewer types the expected full fingerprint. The consumer independently checks the actual inputs and key validity; confirmation returns an in-memory local pin, not a durable store transition or a new source of authority. If an official GitHub source was configured, `discover_github_certificate()` can compare its public certificate with the local pin. Match, mismatch and unavailable are advisory results. None enrolls or replaces trust automatically. ## Generate and protect a new key If no suitable key exists, collect the explicit `KeyIdentity` and use `generate_key(identity=..., profile=..., passphrase_reference=..., secret_resolver=..., keyring_home=...)`. The default profile uses RSA4096 and a two-calendar-year expiry profile. Select `SecretReference` with the supported ENV or Envman provider; resolve only for the operation. Do not put raw passphrases in command arguments, logs, manifests or chat. Keep the returned public certificate and full fingerprint separate from secret material. Key generation alone does not activate the key for any consumer. For native generation input, build `describe_generation_operation()` from the actual identity, profile and selected new or empty key home. Bind it to the owned session with `NativeInputContext`, then call `generate_key()` with that context, an explicit resolver and `passphrase_reference=None`. The form requests matching passphrases. Cancellation before preparation leaves the selected home untouched; failure after generation starts preserves partial material without replay. For byte-envelope signing or opening, an explicitly selected native context can collect the passphrase through the existing private form channel. Build its descriptor with `describe_seal_operation()` or `describe_open_operation()` and pass `native_input=...`, `passphrase_reference=None`, and an explicit resolver to the matching API. Use the actual authorized payload, fingerprints, trust and home selection; do not substitute a display summary for the operation binding. No other secret source silently falls back to this form. Cancel, expiry, owner loss or uncertain handoff stops the attempt without replay. Input acceptance does not prove that signing or decryption succeeded. See the runtime guide's native-input example. Streaming, historical access and durable trust transitions retain their existing explicit inputs in this integration. ## Back up and prove restoration Use `create_protected_backup()` with the owner's full fingerprint, selected capabilities/profile, protected owner passphrase reference and a separately held recovery recipient. Its recovery public keyring must contain public material only. Write the encrypted backup to a new private path. Keep its recovery private key and passphrase independently available; do not add that key as a routine message recipient merely because it protects backups. Exercise `restore_protected_backup()` into an explicitly empty isolated home. Check the returned full fingerprint, capabilities, profile and expiry against the original. Report the actual restore outcome. Retain historical decryption keys as long as old ciphertext must remain readable. Losing every recipient key and usable backup makes that ciphertext unrecoverable. ## Rotate, retire or revoke For routine owner rotation, compose `create_transition_proposal()`, `encrypt_transition_proposal()`, `approve_transition_proposal()` and `verify_approved_transition()`. Delivery is encrypted only to the old owner; its approval binds the exact candidate package. For publisher rotation use `create_publishing_transition_proposal()`, `sign_publishing_transition_proposal()`, `approve_publishing_transition()` and `verify_approved_publishing_transition()`. The current owner authorizes the publisher, and the old publisher proves consent. Apply the serialized approved record through `apply_owner_transition()` or `apply_publisher_transition()` with the expected store ID and revision. These functions independently verify the record and update authority atomically. Observe the new snapshot and effective time. Consumers use current authority for new traffic; only the recorded immediate predecessor gets the bounded overlap. A scheduled transition survives an offline interval. Retire keys after their applicable overlap while retaining required historical decryption material. For compromise, the trusted operator calls `revoke_authority()` for the affected role or exact predecessor. Verify new traffic is denied for that fingerprint and pending transitions are canceled. Do not bypass revocation with routine rotation. ## Recover independent authority If the operational key is unavailable, restoring a backup and replacing authority are separate operations. For replacement, create a short-lived `create_recovery_challenge()` for the exact successor certificate and scope. The candidate signs with `sign_recovery_challenge()` and submits possession through `submit_candidate_proof()`. Use either an already authenticated clean-system/provider-console operator calling `authorize_recovery_locally()` with the exact challenge digest and revision, or a signature from an independently pre-enrolled offline recovery key. The library cannot authenticate the provider for you. Enroll recovery pins through the trusted operator's `enroll_recovery_key()` or initial store setup, never from the challenge itself. Operational or candidate signatures alone cannot authorize recovery. Call `apply_recovery_transition()` and verify the successor is active, the old role is revoked and replay is denied. There is no overlap for emergency recovery. Each remote consumer needs its own authenticated enrollment or independent pinned recovery verification; a local receipt is not portable authority. ## Share an artifact with private provenance Use the shared artifact APIs for a file or binary asset that must retain its encrypted provenance across carriers. Use Agent Q's existing ship/ingest owner for its structured PRD messages; do not reinterpret a generic artifact as a PRD. 1. Select the existing independently enrolled publisher and, when needed, controller owner from the persistent trust store. Select the exact approved recipient fingerprints, scope, purpose, content revision, admission window, and freshness limits. Do not derive these from incoming bytes, filenames, carrier addresses, or downloaded certificates. Confirm disclosure authority for this artifact and audience before preparing an outward transfer. Independently enrolled receivers select their own local store expectations and the sender's exact origin store/revision/epoch as separate approved context. Do not clone the sender's authority database or copy its private key to make an artifact acceptable remotely. 2. Designate an existing private local directory and key home for protected plaintext handling. Check ownership, permissions, and symlinks through the API. Do not treat any machine that can download ciphertext as a trusted plaintext destination. Keep originals untouched and optional source names, paths, hashes, identities, and operational provenance inside the encrypted record. Never use an incoming source path as an output destination. 3. Use `prepare_container()` with file-backed inputs and bounded encrypted provenance. Normal preparation and approval use outer format v2, keeping recipient fingerprints inside encrypted metadata rather than the public header. Check receiving-reader support before sharing; older readers reject v2, and there is no automatic public-v1 fallback. Existing v1 artifacts remain readable under their historical rules and are not rewritten. An authorized controller may wrap a verified v1 origin into v2 while preserving its exact signed metadata and payload ciphertext; that cannot erase earlier public identity disclosure. Configure resource limits for the operation. The default volume target is 100,000,000 serialized bytes with 10% tolerance; prefer whole files and split only an input that cannot fit a fresh volume. Final sizing includes encryption and base64 framing. Missing trust, keys, secrets, or capacity is a local pending result; do not send plaintext instead. 4. When the selected policy requires controller approval, call `approve_container_distribution()` after the controller verifies the origin artifact. Explicitly include that controller in the approved audience. Its outer metadata signature preserves the exact origin-signed metadata and unchanged payload ciphertext; it does not replace the origin's signature or require sharing a master private key with remote recipients. Select all active recipients for a fleet distribution, or the narrower approved audience for an ordinary artifact. 5. Transfer the unchanged opaque bytes through the selected authorized carrier, or copy them manually. Use opaque external names and metadata. Record byte transfer separately from cryptographic verification and local acceptance; neither a successful upload nor a storage account proves recipient identity or fleet-wide acceptance. Protect detailed receipts and carrier locators. 6. At the receiving protected local boundary, use `inspect_container_metadata()` with independently selected expectations. It reads and verifies metadata without fetching bulk content or consuming acceptance state. `accept_container_metadata()` rechecks current authority, freshness, and replay state and records metadata acceptance only. `extract_container_message()` verifies a selected message against that signed inventory before publishing an explicitly named new private output and recording separate payload acceptance. Never overwrite a destination or follow a source path supplied by the artifact. Distinguish an exact accepted object from new acceptance. An observation or cached catalog entry never authorizes output or disclosure. 7. Treat verified content as data. Acceptance does not enroll keys, replace policy, execute instructions, activate services, promote Agent Q work, or grant model/provider disclosure. Preserve separate read and disclosure authority for consumer use. Do not print private provenance in chat or logs. 8. For a historical read, use `open_historical_container_message()` with exact accepted metadata and selected-message ciphertext receipts and the preserved recipient keys. It cannot admit new traffic. Recipient removal affects future encryption; newly enrolled peers do not gain old ciphertext automatically. Retain stricter recovery recipients and report unrecoverable historical content honestly. For ordinary agent reads, configure the existing [container runtime](../../docs/OPENPGP_RUNTIME.md#catalog-backed-ordinary-references) and grant the requested paths separately from provider disclosure. The broker performs authenticated reconstruction; the model does not select keys or operate the container protocol. Optional [snapshot consolidation](../../docs/OPENPGP_RUNTIME.md#configured-consolidation-modes) requires its own explicit write authority and preserves original carriers. The [shared runtime contract](../../docs/OPENPGP_RUNTIME.md#artifacts-across-carriers) defines these boundaries. The named artifact operations above are Python APIs; the runtime's configuration and read commands use their documented CLI owners. A selected private directory is an explicit local handling boundary, not proof of encrypted storage or complete endpoint security. Traffic sizes and timing can remain visible to a carrier. ## Verify the consumer outcome Use the actual selected consumer to sign, encrypt, verify and reconstruct bounded test bytes. Check tampering, wrong participants, stale state and revoked keys are denied. Keep test key material disposable and separate from production. A GnuPG installation or certificate listing alone is not a successful consumer test. Key generation stops its temporary agent before returning. Envelope and transition-signing operations start an agent only for the selected home when needed, preserve an agent already running there, and stop only one they started. Callers do not need to launch an agent manually. Serialize operations that use the same GnuPG home. Only a trusted consumer that has fully verified an envelope may call `record_accepted_content()`. `open_historical_envelope()` opens exact previously accepted ciphertext with its persisted receipt, including authentic signatures whose key later expired or was revoked. It does not admit new messages or promote historical content into a queue. Finish with the full public fingerprints, operation/state revision, useful test results and any genuine recovery limitation; never include secrets or private key material in that report.