diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3a0267..ca65c33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,16 @@ on: pull_request: branches: [main] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse + RUST_BACKTRACE: 1 + jobs: check: name: Build & Verify (xwork + xtask) @@ -14,10 +24,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set up Rust toolchain (1.88.0) + - name: Set up Rust toolchain (1.94.1) uses: dtolnay/rust-toolchain@master with: - toolchain: "1.88.0" + toolchain: "1.94.1" components: rustfmt, clippy - name: Run xwork CI DAG diff --git a/Justfile b/Justfile deleted file mode 100644 index adf1a41..0000000 --- a/Justfile +++ /dev/null @@ -1,98 +0,0 @@ -# Justfile for idp (Identity Provider, Conclave Bot Manager & Directory Reconciler) -# Host Throttling: Physical host ceres runs multiple active agent sessions. -# Shared workstations keep jobs=2 to prevent CPU starvation and OOM. - -set shell := ["bash", "-euo", "pipefail", "-c"] - -jobs := "2" - -# Display available commands -default: - @just --list 2>/dev/null || make help - -# Display this help message -help: - @just --list 2>/dev/null || make help - -# Execute the full compiled projectfile.yaml CI DAG (cargo xwork) -xwork: - cargo xwork - -# Run DBR-admitted verification pipeline with CAS receipts -check: - cargo xtask check --enforce-dbr - -# Verify workspace crate DAG and Wave-0 idp-domain purity -graph-audit: - cargo xtask graph-audit --break-check - -# Verify Wave-0 idp-domain has zero I/O or runtime dependencies -zero-io-domain: - cargo xtask zero-io-domain - -# Validate projectfile.yaml schema and CI nodes -projectfile-check: - cargo xtask projectfile-check - -# Verify stages.rs matches projectfile.yaml -stages-check: - cargo xtask stages-check - -# Validate markdown specs in specs/*.md -spec-check: - cargo xtask spec-check - -# Verify active rustc matches rust-toolchain.toml -toolchain-check: - cargo xtask toolchain-check - -# Audit merged local git branches -branch-hygiene: - cargo xtask branch-hygiene --dry-run - -# Compile the workspace with locked dependencies and host throttling -build: - cargo build --workspace -j {{jobs}} - -# Install idp CLI to ~/.cargo/bin/idp -install: - cargo install --path crates/idp-cli -j {{jobs}} - -# Format all code -fmt: - cargo fmt --all - -# Check code formatting without modifying -fmt-check: - cargo fmt --all -- --check - -# Lint with clippy, warnings are errors -clippy: - cargo clippy --workspace --all-targets -j {{jobs}} -- -D warnings - -# Run unit and integration tests with bounded threads -test: - cargo test --workspace -j {{jobs}} - -# Run doc tests -doc-test: - cargo test --doc --workspace -j {{jobs}} - -# What the CI rust job runs -ci: - cargo xwork - cargo xtask graph-audit --break-check - cargo xtask check --break-check - -# Audit licenses, bans, and advisories -deny: - cargo deny check - -# Check dependencies for known advisories -audit: - cargo audit - -# Build CLI and run smoke tests -smoke: - cargo build --package idp-cli -j {{jobs}} - cargo run --package idp-cli -j {{jobs}} -- list diff --git a/Makefile b/Makefile index 7c4947d..40c07a3 100644 --- a/Makefile +++ b/Makefile @@ -1,129 +1,90 @@ -# Makefile for idp -# Standard POSIX wrapper that awk-parses recipes directly from Justfile. +# Makefile for idp (Identity Provider, Conclave Bot Manager & Directory Reconciler) +# Host Throttling: Physical host ceres runs multiple active agent sessions. +# Shared workstations keep JOBS=2 to prevent CPU starvation and OOM. + SHELL := bash .SHELLFLAGS := -euo pipefail -c .DEFAULT_GOAL := help -.ONESHELL: JOBS ?= 2 - export JOBS -JUST := $(shell command -v just 2>/dev/null) - -# Discover available recipe names from Justfile (excluding help and default) -TARGETS := $(shell awk '(/^[a-zA-Z0-9_-]+ *:[^=]/ || /^[a-zA-Z0-9_-]+ *:$$/) && !/^[a-zA-Z0-9_-]+ *:=/ { split($$1, a, ":"); t = a[1]; if (t != "help" && t != "default") print t }' Justfile 2>/dev/null) - -.PHONY: $(TARGETS) help default - -define AWK_PARSER -BEGIN { - vars["jobs"] = jobs -} -# Capture variable definitions: var := "val" -/^[a-zA-Z0-9_-]+ *:=/ { - var = $$1 - val = $$0 - sub(/^[a-zA-Z0-9_-]+ *:= *"/, "", val) - sub(/".*$$/, "", val) - if (!(var in vars)) vars[var] = val - next -} -# Capture doc comment above recipe -/^# / { - sub(/^# */, "") - last_doc = $$0 - next -} -# Capture recipe signature -(/^[a-zA-Z0-9_-]+ *:[^=]/ || /^[a-zA-Z0-9_-]+ *:$$/) && !/^[a-zA-Z0-9_-]+ *:=/ { - curr = $$1 - sub(/:.*/, "", curr) - header = $$0 - sub(/^[a-zA-Z0-9_-]+ *: */, "", header) - deps[curr] = header - all_targets[curr] = 1 - doc[curr] = last_doc - order[++target_count] = curr - last_doc = "" - next -} -# Capture recipe body lines and interpolate variables -/^[ \t]+/ && curr != "" { - line = $$0 - sub(/^[ \t]+/, "", line) - for (v in vars) { - gsub("\\{\\{ *" v " *\\}\\}", vars[v], line) - } - gsub(/[$$][$$]/, "$$", line) - body[curr] = (body[curr] ? body[curr] "\n" : "") line - next -} -!/^[ \t]/ { - curr = "" - last_doc = "" -} -function emit(t, n, d, i, k, lines, cmd) { - if (!(t in all_targets)) { - print "echo \"error: unknown recipe: " t "\" >&2; exit 1" - return - } - if (deps[t] != "") { - n = split(deps[t], d, " ") - for (i = 1; i <= n; i++) { - if (d[i] != "") emit(d[i]) - } - } - if (body[t] != "") { - k = split(body[t], lines, "\n") - for (i = 1; i <= k; i++) { - cmd = lines[i] - sub(/^@/, "", cmd) - print cmd - } - } -} -function show_help() { - print "Usage: make " - print "" - print "Available recipes (parsed from Justfile):" - for (i = 1; i <= target_count; i++) { - t = order[i] - if (t != "default" && t != "help") { - printf " \033[36m%-24s\033[0m %s\n", t, (doc[t] ? doc[t] : "") - } - } -} -END { - if (target == "help" || target == "default" || target == "") { - show_help() - } else { - print "set -euo pipefail" - emit(target) - } -} -endef -export AWK_PARSER - -help: - @if [ -n "$(JUST)" ]; then \ - $(JUST) --list; \ - else \ - awk -v target="help" -v jobs="$(JOBS)" "$$AWK_PARSER" Justfile; \ - fi +.PHONY: help default xwork check graph-audit zero-io-domain projectfile-check \ + stages-check spec-check toolchain-check branch-hygiene build install \ + fmt fmt-check clippy test doc-test ci deny audit smoke + +##@ General + +help: ## Show this help message + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-22s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) default: help -$(TARGETS): - @if [ -n "$(JUST)" ]; then \ - $(JUST) --set jobs "$(JOBS)" "$@"; \ - else \ - awk -v target="$@" -v jobs="$(JOBS)" "$$AWK_PARSER" Justfile | $(SHELL); \ - fi - -%: - @if [ -n "$(JUST)" ]; then \ - $(JUST) --set jobs "$(JOBS)" "$*"; \ - else \ - awk -v target="$*" -v jobs="$(JOBS)" "$$AWK_PARSER" Justfile | $(SHELL); \ - fi +##@ Verification & CI Gates (cargo xtask) + +xwork: ## Execute the full compiled projectfile.yaml CI DAG (cargo xwork) + cargo xwork + +check: ## Run DBR-admitted verification pipeline with CAS receipts + cargo xtask check --enforce-dbr + +ci: ## Run full CI verification gates + cargo xwork + cargo xtask graph-audit --break-check + cargo xtask check --break-check + +graph-audit: ## Verify workspace crate DAG and Wave-0 idp-domain purity + cargo xtask graph-audit --break-check + +zero-io-domain: ## Verify Wave-0 idp-domain has zero I/O or runtime dependencies + cargo xtask zero-io-domain + +projectfile-check: ## Validate projectfile.yaml schema and CI nodes + cargo xtask projectfile-check + +stages-check: ## Verify stages.rs matches projectfile.yaml + cargo xtask stages-check + +spec-check: ## Validate markdown specs in specs/*.md + cargo xtask spec-check + +toolchain-check: ## Verify active rustc matches rust-toolchain.toml + cargo xtask toolchain-check + +branch-hygiene: ## Audit merged local git branches + cargo xtask branch-hygiene --dry-run + +##@ Build & Install + +build: ## Compile the workspace with host throttling (-j 2) + cargo build --workspace -j $(JOBS) + +install: ## Install idp CLI to ~/.cargo/bin/idp + cargo xtask install + +smoke: ## Build CLI and run smoke tests + cargo build --package idp-cli -j $(JOBS) + cargo run --package idp-cli -j $(JOBS) -- bot list + +##@ Code Quality & Supply Chain + +fmt: ## Format all Rust code + cargo fmt --all + +fmt-check: ## Check code formatting without modifying + cargo fmt --all -- --check + +clippy: ## Lint workspace with clippy (-D warnings) + cargo clippy --workspace --all-targets -j $(JOBS) -- -D warnings + +test: ## Run unit and integration tests with bounded threads + cargo test --workspace -j $(JOBS) + +doc-test: ## Run documentation tests + cargo test --doc --workspace -j $(JOBS) + +deny: ## Audit licenses, bans, and advisories via cargo-deny + cargo deny check + +audit: ## Check dependencies for known security advisories + cargo audit diff --git a/crates/idp-cli/Cargo.toml b/crates/idp-cli/Cargo.toml index 01a47ce..ebfa555 100644 --- a/crates/idp-cli/Cargo.toml +++ b/crates/idp-cli/Cargo.toml @@ -19,6 +19,7 @@ workspace = true [dependencies] idp = { path = "../idp" } anyhow.workspace = true +serde.workspace = true serde_json.workspace = true tokio.workspace = true tracing.workspace = true diff --git a/crates/idp-cli/src/server.rs b/crates/idp-cli/src/server.rs index e008aec..e169b78 100644 --- a/crates/idp-cli/src/server.rs +++ b/crates/idp-cli/src/server.rs @@ -494,12 +494,7 @@ pub fn build_bot_dcr_metadata( .map_err(|e| e.to_string())?; let scope_set: std::collections::BTreeSet = scopes - .unwrap_or_else(|| { - vec![ - "openid".to_string(), - "estate:agent:execute".to_string(), - ] - }) + .unwrap_or_else(|| vec!["openid".to_string(), "estate:agent:execute".to_string()]) .into_iter() .filter(|s| !s.trim().is_empty()) .collect(); @@ -537,7 +532,9 @@ async fn dcr_metadata_handler( Ok(meta) => (StatusCode::OK, Json(meta)).into_response(), Err(msg) => ( StatusCode::BAD_REQUEST, - Json(serde_json::json!({ "error": "invalid_client_metadata", "error_description": msg })), + Json( + serde_json::json!({ "error": "invalid_client_metadata", "error_description": msg }), + ), ) .into_response(), } @@ -737,7 +734,10 @@ mod tests { // 4. Positive control: write PEM key and verify /.well-known/jwks/sindri.json returns 200 OK state .key_store - .write_key("sindri", "-----BEGIN RSA PRIVATE KEY-----\nTEST_SINDRI_KEY\n-----END RSA PRIVATE KEY-----\n") + .write_key( + "sindri", + "-----BEGIN RSA PRIVATE KEY-----\nTEST_SINDRI_KEY\n-----END RSA PRIVATE KEY-----\n", + ) .expect("write sindri key"); let ok_jwks = http @@ -825,11 +825,13 @@ mod tests { // Verify by a second path: read the persisted receipt from disk and confirm secrets are redacted let receipt_path = temp.path().join("sindri-dcr.json"); - assert!(receipt_path.exists(), "sindri-dcr.json must be written to KeyStore"); + assert!( + receipt_path.exists(), + "sindri-dcr.json must be written to KeyStore" + ); let persisted_raw = std::fs::read_to_string(&receipt_path).expect("read receipt"); assert!(!persisted_raw.contains("super-secret-do-not-persist")); assert!(!persisted_raw.contains("rat-secret-token")); assert!(persisted_raw.contains("hydra-elf-sindri-001")); } } - diff --git a/crates/idp/Cargo.toml b/crates/idp/Cargo.toml index a0ded87..335f877 100644 --- a/crates/idp/Cargo.toml +++ b/crates/idp/Cargo.toml @@ -22,6 +22,8 @@ jsonwebtoken.workspace = true chrono.workspace = true serde_yaml.workspace = true regex.workspace = true +sha2.workspace = true [dev-dependencies] tempfile.workspace = true +tokio.workspace = true