diff --git a/casts/delivery.yaml b/casts/delivery.yaml index cb76500..901121d 100644 --- a/casts/delivery.yaml +++ b/casts/delivery.yaml @@ -9,6 +9,7 @@ runes: - core/rules/AnchorWorkingDirectory - core/rules/PreferTrash - core/rules/CaptureOnTouch + - core/rules/DeclareSecrets - development/skills/MergeTrain - development/skills/ForgeCycle - development/skills/AgentTeam diff --git a/docs/changes/declare-secrets-per-repository/proposal.md b/docs/changes/declare-secrets-per-repository/proposal.md new file mode 100644 index 0000000..cc29237 --- /dev/null +++ b/docs/changes/declare-secrets-per-repository/proposal.md @@ -0,0 +1,24 @@ +--- +status: proposed +--- + +# Declare secrets per repository + +## Why + +The runedeck stack now declares secrets with SecretSpec ([SecretSpec][SECRETSPEC]). The skeleton gives each repository a `secretspec.toml`. Provision declares the machine's credentials and publishes the manifest at `~/.config/provision/secretspec.toml`. The owner's keys stay in the Keychain, and rune launch reads its credentials through that manifest. An agent that does not know this still reads `~/.env` or puts a key on a command line. A core rule tells every session how to declare, read, and pass a secret. + +## What Changes + +- `runes/core/rules/DeclareSecrets.md` tells an agent to declare each secret in the repository's `secretspec.toml` and to read it only through secretspec. Values stay out of the conversation and off argv, and every call gives a reason. +- The `delivery` cast selects the rule. The `core` cast selects it through `core/**`. + +## Capabilities + +- declare-secrets-per-repository (new) + +## Impact + +- One new rule and one cast entry. The rule enters without a provenance sidecar, because it is first-party content. + +[SECRETSPEC]: https://github.com/cachix/secretspec diff --git a/docs/changes/declare-secrets-per-repository/pull-request.md b/docs/changes/declare-secrets-per-repository/pull-request.md new file mode 100644 index 0000000..9c6af9b --- /dev/null +++ b/docs/changes/declare-secrets-per-repository/pull-request.md @@ -0,0 +1,19 @@ +Adds the DeclareSecrets rule: declare each secret in `secretspec.toml`, read it only through secretspec, and keep values out of the conversation. + +## Plan + +Change `declare-secrets-per-repository`: proposal, one ADDED delta (`declare-secrets-per-repository`), and tasks under `docs/changes/declare-secrets-per-repository/`. + +## Changes + +- Adds `runes/core/rules/DeclareSecrets.md`: declare with `secretspec add`, read with `secretspec run` or `secretspec get`, pass values on stdin, give every call a `--reason`, and use `~/.config/provision/secretspec.toml`, with the profile of the account, for the machine's credentials. +- Adds the rule to `casts/delivery.yaml`. The `core` cast selects it through `core/**`. + +## Testing + +- `rune validate`: 0 errors, `core/rules/DeclareSecrets.md` passes. +- `rune spec validate declare-secrets-per-repository` passes. The guarded push pipeline passed on this head. + +## Release Notes + +- New core rule DeclareSecrets for declaring and reading secrets through secretspec. diff --git a/docs/changes/declare-secrets-per-repository/specs/declare-secrets-per-repository/spec.md b/docs/changes/declare-secrets-per-repository/specs/declare-secrets-per-repository/spec.md new file mode 100644 index 0000000..d1fdbe3 --- /dev/null +++ b/docs/changes/declare-secrets-per-repository/specs/declare-secrets-per-repository/spec.md @@ -0,0 +1,20 @@ +## ADDED Requirements + +### Requirement: Agent declares each secret + +The deck MUST hold a rule about secrets. The rule MUST tell an agent to declare every secret a repository reads in that repository's secret declaration, with a description of its purpose. + +#### Scenario: Script needs a new token + +- **WHEN** an agent adds a script that reads a token the repository did not use before +- **THEN** the agent adds the token to the repository's secret declaration with a description + +### Requirement: Secret values stay out of the conversation + +The rule MUST tell an agent to read a secret only through the secret manager. It MUST forbid printing a value or reading one into the conversation. It MUST tell the agent to pass a value to a program on stdin and to give every read a reason. + +#### Scenario: Command needs a credential + +- **WHEN** an agent runs a command that needs a credential +- **THEN** the agent runs the command under the secret manager and reports only its result +- **AND** no credential value appears in the transcript or in a process argument diff --git a/docs/changes/declare-secrets-per-repository/tasks.md b/docs/changes/declare-secrets-per-repository/tasks.md new file mode 100644 index 0000000..15950d7 --- /dev/null +++ b/docs/changes/declare-secrets-per-repository/tasks.md @@ -0,0 +1,15 @@ +# Tasks + +## 1. Authoring + +- [x] 1.1 Add `runes/core/rules/DeclareSecrets.md` +- [x] 1.2 Add the rule to the `delivery` cast + +## 2. Verification + +- [x] 2.1 `rune validate` passes with the rule present +- [ ] 2.2 One bench run against a baseline with no rule (BenchArtifact): an agent asked to call an authenticated API reads the key through secretspec and prints no value + +## 3. Record + +- [ ] 3.1 Archive merges the delta into `docs/specs/` diff --git a/runes/core/rules/DeclareSecrets.md b/runes/core/rules/DeclareSecrets.md new file mode 100644 index 0000000..e740d37 --- /dev/null +++ b/runes/core/rules/DeclareSecrets.md @@ -0,0 +1,9 @@ +Declare every secret a repository reads in `secretspec.toml` at the repository root, each with a description. Add one with `secretspec add --description ""`. Read a secret only through `secretspec run -- ` or `secretspec get `, never from a dotenv file or a shell profile. + +Never print a secret value, and never read one into the conversation. When a command needs a secret, run it under `secretspec run` and report the result. Use `secretspec get` only where a pipe or a command substitution takes its output. A bare call prints the value into the transcript. Pass a value to a program on stdin, because a process list shows every argument. Never type or paste a value yourself. Ask the owner to store a new secret with `secretspec set `, which prompts and does not echo. A program that makes a value pipes it into `secretspec set --from-file -`. + +Never show secretspec's own error text: a dotenv parse error quotes the line, value included. Send the stderr of `secretspec get` to `/dev/null` and report its exit code. + +Give every call a reason with `--reason ""`. By default SecretSpec refuses an agent session that gives none, and a provider that keeps an audit log writes the reason into it. + +runedeck/provision declares the machine's credentials, the harness keys among them, and publishes that manifest at `~/.config/provision/secretspec.toml`. A repository that reads one of these credentials reads it from that manifest and does not declare it again. Each account reads its own profile: `owner` on the owner's machines, `agents` for the agent user on Cortex. A command that needs one runs as `secretspec run --file ~/.config/provision/secretspec.toml --profile owner --reason "" -- `. `rune launch` and `rune run` read an unset `from_env` key from that manifest. Do not export a credential in the shell to start a launch. diff --git a/secretspec.toml b/secretspec.toml index 644add2..02edbe8 100644 --- a/secretspec.toml +++ b/secretspec.toml @@ -1,8 +1,8 @@ #:schema https://secretspec.dev/schema/secretspec.schema.json # The secrets this repository's scripts and checks read. Declare a new one with # `secretspec add --description ""`, and read it with -# `secretspec run -- ` or `secretspec get `. No value ever enters -# the repository. On a workstation, values come from the provider the owner's +# `secretspec run --reason "" -- `. An agent session must give a +# reason. No value ever enters the repository. On a workstation, values come from the provider the owner's # secretspec config names, the Keychain by default. The ci profile reads them # from the job environment only. # Reference: https://secretspec.dev/reference/configuration/