Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .claude/skills/sc-cli-reference/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ cargo run --bin sc -- secret add <name> --to <recipient> --value <val>
cargo run --bin sc -- secret grant <name> --to <recipient> --identity <key>
cargo run --bin sc -- secret revoke <name> --recipient-id <id>
cargo run --bin sc -- secret list
cargo run --bin sc -- run -- <cmd> [args…] # inject decrypted secrets + run command
cargo run --bin sc -- run [--secrets-fd N] -- <cmd> [args…] # inject decrypted secrets + run command;
# --secrets-fd N (unix, N in 3..=1023) passes them on fd N as
# NUL-terminated NAME=VALUE records instead of env vars
# (SC_SECRETS_FD names N); ADR-0052
cargo run --bin sc -- gc # pack reachable objects + prune unreachable
cargo run --bin sc -- gc --prune-expire 7d # custom grace window
cargo run --bin sc -- export --to <git-repo> # write current branch history to Git
Expand Down
7 changes: 5 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ transport-adjacent. The rest, imperatively:
- **Secret injection is an authorized local process context, NOT isolation:**
same-user processes, crash dumps, and shell wrappers can observe the child
env. The parent's buffer is zeroized; the child's copy cannot be.
`sc run --secrets-fd N` (ADR-0052, unix) keeps the secrets out of the
environment (they arrive on fd N as NUL-terminated `NAME=VALUE` records,
`SC_SECRETS_FD` names it): hygiene against env dumps and inheritance, still
not isolation. `sc ws run` and `sc work --with-secrets` use the environment.
- **Sparse is checkout-only** and has one disk-hygiene boundary: an in-sparse
conflict co-occurring with an out-of-sparse protected/plain clean change can
leave that out-of-sparse plaintext on disk until the next materializing
Expand Down Expand Up @@ -264,8 +268,7 @@ transport-adjacent. The rest, imperatively:
Deferred work is tracked in **`ROADMAP.md` → Deferred** (single source of
truth — do not re-list items here). Notable standing entries: transparent
lazy-fetch for partial clones, per-case gap-tolerant merge/replay on partial
clones, fd/stdin
secret injection, CA-path validation alongside TOFU pinning, and pin-management
clones, CA-path validation alongside TOFU pinning, and pin-management
UX (`sc tls`).

## Agent skills
Expand Down
9 changes: 4 additions & 5 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -799,11 +799,10 @@ scale-&-reach horizon):
is minted 0600-from-first-byte via a unix-only `OpenOptions::mode` call;
there is no non-unix fallback today, so the key file is left world-readable
on a non-unix target. A non-unix permission-hardening path is deferred.
- **fd/stdin secret injection (P28).** `sc run` hands decrypted secrets to
the child via its environment — observable by same-user processes,
crash dumps, and shell wrappers, per the tightened threat-model wording.
An alternative injection path (an fd or stdin the child reads instead of
inheriting an env var) would shrink that exposure and is deferred.
- **fd secret injection — shipped (ADR-0052).** `sc run --secrets-fd N` hands the
secrets to the command on a descriptor (NUL-terminated `NAME=VALUE` records)
instead of its environment. Not built: the same mode for `sc ws run` and
`sc work --with-secrets`, and a stdin variant.
- **`--max-object-size` operator config knob (P28).** `MAX_OBJECT_SIZE`
(256 MiB) is a compile-time constant anchoring every untrusted-length
guard; letting an operator raise or lower it per-deployment is deferred.
Expand Down
21 changes: 18 additions & 3 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,18 @@ enum Cmd {
/// Injected secrets are visible to the child and any same-user process,
/// crash dump, or shell wrapper — an authorized local-process boundary,
/// not isolation.
///
/// With `--secrets-fd N` the secrets stay out of the environment: they
/// arrive on file descriptor N as NUL-terminated NAME=VALUE records (read
/// to EOF), and SC_SECRETS_FD=N names it.
Run {
/// Identity file (default ~/.sc/identity or $SC_IDENTITY).
#[arg(long)]
identity: Option<PathBuf>,
/// Hand the secrets to the command on this file descriptor (3 to
/// 1023) instead of in its environment. Unix only.
#[arg(long, value_name = "FD")]
secrets_fd: Option<i32>,
/// Command and args after `--`.
#[arg(last = true, required = true)]
cmd: Vec<String>,
Expand Down Expand Up @@ -951,7 +959,11 @@ fn main() -> Result<()> {
identity,
} => run_rebase(target, r#continue, abort, &resolve_author(author), identity),
Cmd::Secret { op } => run_secret(op),
Cmd::Run { identity, cmd } => run_run(identity, cmd),
Cmd::Run {
identity,
secrets_fd,
cmd,
} => run_run(identity, secrets_fd, cmd),
Cmd::Work {
agents,
name,
Expand Down Expand Up @@ -3080,10 +3092,13 @@ fn run_escrow(op: EscrowOp) -> Result<()> {
Ok(())
}

fn run_run(identity: Option<PathBuf>, cmd: Vec<String>) -> Result<()> {
fn run_run(identity: Option<PathBuf>, secrets_fd: Option<i32>, cmd: Vec<String>) -> Result<()> {
let repo = open_repo()?;
let sk = load_identity(identity)?;
let code = repo.run(&sk, &cmd)?;
let code = match secrets_fd {
Some(fd) => repo.run_with_secrets_fd(&sk, &cmd, fd)?,
None => repo.run(&sk, &cmd)?,
};
// `process::exit` skips destructors, so the repo's RepoLock would never run
// its Drop and `.sc/lock` would leak — bricking the next `sc` command with a
// spurious `Locked` error. Drop the repo (releasing the lock) before exiting.
Expand Down
Loading
Loading