feat(sci): the CLI's SCI API access — proof of concept alongside foundry#171 #75
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 385 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.356
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #75"
general
weight: 0.35
smith-xyz
Proof of concept alongside the architecture plan foundry#171 — implementation-to-plan pairing for user API access (Phase 2 of the plan). Not for merge until the foundry plan is approved.
Note: traust-cli has no \
development\branch (main is the trunk), so this branches off main. Sibling PR: source-code-intelligence#449 (Phase 1 — the API's session-registration endpoint this client calls).What
\
traust sci\— the CLI talks to SCI's API as the user, with console-equivalent permissions (the token is the user; SCI's RBAC is transport-agnostic — no scoping in v1):traust sci login\— authorization-code + PKCE loopback as the universal primary (works against the corporate Keycloak on stage/prod), RFC 8628 device code auto-selected when the issuer's discovery publishes \device_authorization_endpoint\(e.g. integration Dex). \--flow=auto|device|pkce\, \--listen\for the loopback port (default 127.0.0.1:8976), \--issuer\/\--client-id\(default \sci-cli\).traust sci logout\— revokes the server-side session (bearer hash) and deletes the local credential.traust sci status\— stored credential, expiry, storage backend, who SCI sees (\/api/v1/me\).traust sci inventory list|get <id>\, \traust sci findings list <inventory-id>\— the read-only v1 queries, tables by default, \--json\for scripting.POST /api/v1/auth/session\(foundry#171 Phase 1) so the bearer path admits it; on 401 it refreshes once, re-registers, and retries once before failing.Credential storage (keychain-first, 0600 fallback)
OS keychain via go-keyring (macOS Keychain / Secret Service / Credential Manager) with a 0600 file fallback under \
<workspace>/cli/sci-credentials.json\for headless hosts; the fallback refuses world-readable files. Never in \state.json\, never on argv, never logged. The SCI-side registration never receives the refresh token.Verified
go test -race ./...\green (including new \internal/sci\and \cmd/sci_test.go\): PKCE flow against a mock issuer (loopback callback actually fires), device-code flow with \authorization_pending\then success, auto-selection when the issuer advertises device code, refresh keeps the stored refresh token when the issuer doesn't rotate, file-store roundtrip + 0600/perm-refusal, 401→refresh→retry against a stub SCI, forbidden surfaces cleanly.go vet ./...\clean, \gofmt\clean, \make build\, \make check-version\green.Live testing still needed
sci-cli\public client (stage/prod — platform team, foundry#171 Q11).Cc @smith-xyz @chubirka