mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 18:07:00 +01:00
Forward Pi provider credentials through the native session binding
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
f332f79e6e
commit
aa67de3113
5 files changed
+153
-5
No files matched your search
@@ -2177,3 +2177,47 @@ all failed release evidence.
|
||||
All 72 account BYOK provider rows are unconfigured. The campaign retains its
|
||||
$100 budget, frozen model/profile and failed-case holds. Recorded rollout/rollback
|
||||
remains conditional on every release gate passing.
|
||||
|
||||
|
||||
## Native Linux admission and Pi credential forwarding — 2026-10-07
|
||||
|
||||
- Frozen runtime `efd4df03d5c472dc8051461f38e16b5f3b62ce01` was built natively
|
||||
with Node 24.21.0 and Rust 1.97.1 on an owned disposable Linux host. Normal
|
||||
public CLI/server packages installed and `runtime setup pi`, installed graph
|
||||
verification, public daemon admission/retirement, health and browser onboarding
|
||||
passed. External probe source is `f332f79e6e9fc40fa69fbf8d9dfc544acc531e7f`;
|
||||
its change is probe metadata only. Pi remains profile 16, thinking low.
|
||||
- Latest `f332f79e` PR checks were 54 successful, two skipped, no failures, with
|
||||
an exact-head Greptile 5/5 review and no unresolved review threads. The normal
|
||||
Canary public-install probe passed; its merge source is distinct from `efd4`.
|
||||
- The first real `extended-harnesses.runner-acpx-pi.local.file-edit-validate`
|
||||
attempt failed during `session.open`, with independently confirmed cleanup
|
||||
and no token usage observed. Before/after key usage was USD 0.445246261, BYOK
|
||||
zero, lifetime limit USD 5. No unchanged paid retry was made.
|
||||
- A separate invalid-key diagnostic reproduced the startup rejection. Captured
|
||||
runtime context and the Rust-projected dynamic tool catalog were valid. Direct
|
||||
installed-sidecar startup exposed `ENOSPC` while copying the verified Pi
|
||||
distribution. Removing only the completed npm download cache reclaimed
|
||||
1,116,352 KiB without changing installed packages or archived package bytes.
|
||||
Direct admission with the captured context then passed with no prompt. A full
|
||||
installed diagnostic subsequently reached the provider turn and failed with
|
||||
the expected invalid-key service error; startup and cleanup both succeeded.
|
||||
These diagnostics are not qualification passes.
|
||||
- The Rust sidecar launcher had an independent production restriction: Pi
|
||||
forwarded only `OPENROUTER_API_KEY`. This change forwards bounded credential
|
||||
names from the authenticated controller's Pi session binding, including native
|
||||
provider keys and explicit custom provider references. The sidecar retains its
|
||||
exact session/configuration validation. Process-control variables and malformed
|
||||
bindings fail closed. No model allowlist, model fallback or new default is added.
|
||||
- A real child-process regression passes OpenRouter, Gemini and custom-provider
|
||||
bindings while excluding unrelated credentials; malformed/duplicate bindings
|
||||
and process-control names are rejected. Full Rust validation passed 687
|
||||
tests (two ignored), plus the final binding guard and 15 process-transport
|
||||
tests after tightening loader/shell variable exclusions. Runtime declarations and fixture
|
||||
membership are unchanged; the new shipping source must be frozen and rebuilt.
|
||||
- The owned image workflow `37621428993`, pinned to `efd4`, remained unassigned
|
||||
on the EC2 fleet. A concrete GitHub-hosted Linux fallback patch is prepared,
|
||||
preserving maintainer authorization and source pins. The explicit workflow
|
||||
exception approval remains pending; no workflow edit, merge or deployment was
|
||||
performed. Real accepted Product/Runner qualification still needs 26 + 7
|
||||
passes on the corrected installed artifact set. Historical passes do not transfer.
|
||||
@@ -61,6 +61,8 @@ the caller's selected model; its serialized name preserves recovery identities.
|
||||
Historical profile fixtures remain immutable evidence, not release declarations.
|
||||
|
||||
Pi credentials are selected from the explicit run environment and remain session-bound.
|
||||
The native Rust launcher forwards the controller-bound credential names, including
|
||||
custom provider references, without restricting Pi to an OpenRouter credential.
|
||||
Built-in providers can use their usual API-key environment variables. Custom Pi
|
||||
providers are supported through `PAPERCLIP_PI_PROVIDERS`: a JSON object containing
|
||||
the native `models.json` provider entries (without the outer `providers` key).
|
||||
|
||||
@@ -97,6 +97,58 @@ fn session_open_timeout(agent: &str, ordinary: Duration) -> Duration {
|
||||
}
|
||||
}
|
||||
|
||||
// Pi's provider catalog is caller-selected. The authenticated controller binds
|
||||
// credential names (including custom models.json references); a Rust provider
|
||||
// roster would silently drop credentials before the sidecar can validate them.
|
||||
fn pi_credential_environment_keys(binding: Option<&str>) -> Result<Vec<String>, LocalRunnerError> {
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
struct Binding {
|
||||
schema: String,
|
||||
agent: String,
|
||||
session_id: String,
|
||||
names: Vec<String>,
|
||||
}
|
||||
let invalid = || LocalRunnerError::invalid("Pi credentials require a valid controller binding");
|
||||
let Some(raw) = binding else {
|
||||
return Ok(Vec::new());
|
||||
};
|
||||
if raw.len() > 4_096 {
|
||||
return Err(invalid());
|
||||
}
|
||||
let value: Binding = serde_json::from_str(raw).map_err(|_| invalid())?;
|
||||
if value.schema != "paperclip.acpx_credential_binding.v1"
|
||||
|| value.agent != "pi"
|
||||
|| !is_stable_id(&value.session_id, SHORT_STABLE_ID_CHARS)
|
||||
|| value.names.len() > 128
|
||||
{
|
||||
return Err(invalid());
|
||||
}
|
||||
let mut seen = BTreeSet::new();
|
||||
for name in &value.names {
|
||||
let valid_name = name.len() <= 128
|
||||
&& name.as_bytes().first().is_some_and(u8::is_ascii_uppercase)
|
||||
&& name
|
||||
.bytes()
|
||||
.all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == b'_');
|
||||
let protected_name = (name.starts_with("PAPERCLIP_") && name != "PAPERCLIP_PI_PROVIDERS")
|
||||
|| name.starts_with("NODE_")
|
||||
|| name.starts_with("NPM_")
|
||||
|| name.starts_with("DYLD_")
|
||||
|| name.starts_with("LD_")
|
||||
|| matches!(
|
||||
name.as_str(),
|
||||
"PATH" | "HOME" | "SHELL" | "TMPDIR" | "BASH_ENV" | "ENV" | "ZDOTDIR"
|
||||
);
|
||||
if !valid_name || protected_name || !seen.insert(name) {
|
||||
return Err(invalid());
|
||||
}
|
||||
}
|
||||
// The sidecar still checks every name against Pi's pinned SDK/custom
|
||||
// configuration and the exact session.open identity before provider launch.
|
||||
Ok(value.names)
|
||||
}
|
||||
|
||||
impl AcpxSidecarTransport {
|
||||
pub fn start(config: &AcpxSidecarTransportConfig) -> Result<Self, LocalRunnerError> {
|
||||
Self::start_with_environment_keys(config, &[])
|
||||
@@ -119,7 +171,7 @@ impl AcpxSidecarTransport {
|
||||
"PAPERCLIP_AI_PROVIDER_KEY",
|
||||
],
|
||||
"grok" => &["XAI_API_KEY", "PAPERCLIP_ACPX_GROK_AUTH_JSON_SECRET"],
|
||||
"pi" => &["OPENROUTER_API_KEY"],
|
||||
"pi" => &[],
|
||||
"cursor" => &["CURSOR_API_KEY", "CURSOR_AUTH_TOKEN"],
|
||||
"copilot" => &["COPILOT_GITHUB_TOKEN"],
|
||||
_ => {
|
||||
@@ -174,6 +226,16 @@ impl AcpxSidecarTransport {
|
||||
"CLAUDE_CODE_SUBAGENT_MODEL",
|
||||
]);
|
||||
}
|
||||
let pi_keys = if agent == "pi" {
|
||||
pi_credential_environment_keys(
|
||||
std::env::var("PAPERCLIP_ACPX_CREDENTIAL_BINDING")
|
||||
.ok()
|
||||
.as_deref(),
|
||||
)?
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
keys.extend(pi_keys.iter().map(String::as_str));
|
||||
keys.extend_from_slice(credential_keys);
|
||||
let mut transport = Self::start_with_environment_keys(config, &keys)?;
|
||||
transport.session_open_timeout = session_open_timeout(agent, config.request_timeout);
|
||||
@@ -818,6 +880,36 @@ fn response_error_classification(error: &ResponseError) -> &'static str {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn pi_credentials_require_a_bounded_binding_without_process_control_variables() {
|
||||
assert!(pi_credential_environment_keys(None).unwrap().is_empty());
|
||||
for name in [
|
||||
"NODE_OPTIONS",
|
||||
"PATH",
|
||||
"HOME",
|
||||
"LD_PRELOAD",
|
||||
"LD_LIBRARY_PATH",
|
||||
"BASH_ENV",
|
||||
"ENV",
|
||||
"ZDOTDIR",
|
||||
"DYLD_INSERT_LIBRARIES",
|
||||
"PAPERCLIP_NATIVE_MCP_TOKEN",
|
||||
"INVALID-NAME",
|
||||
] {
|
||||
let binding = json!({"schema":"paperclip.acpx_credential_binding.v1", "agent":"pi", "sessionId":"session-1", "names":[name]});
|
||||
assert!(pi_credential_environment_keys(Some(&binding.to_string())).is_err());
|
||||
}
|
||||
for binding in [
|
||||
json!({"schema":"other", "agent":"pi", "sessionId":"session-1", "names":[]}),
|
||||
json!({"schema":"paperclip.acpx_credential_binding.v1", "agent":"cursor", "sessionId":"session-1", "names":[]}),
|
||||
json!({"schema":"paperclip.acpx_credential_binding.v1", "agent":"pi", "sessionId":"session-1", "names":["MY_PI_KEY", "MY_PI_KEY"]}),
|
||||
json!({"schema":"paperclip.acpx_credential_binding.v1", "agent":"pi", "sessionId":"session-1", "names":[], "extra":true}),
|
||||
] {
|
||||
assert!(pi_credential_environment_keys(Some(&binding.to_string())).is_err());
|
||||
}
|
||||
assert!(pi_credential_environment_keys(Some(&"x".repeat(4_097))).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_pi_cold_open_gets_the_longer_admission_budget() {
|
||||
let ordinary = Duration::from_secs(30);
|
||||
|
||||
@@ -229,7 +229,7 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
|
||||
"hasToken": std::env::var("PAPERCLIP_NATIVE_MCP_TOKEN").is_ok(),
|
||||
"hasUnrelatedSecret": std::env::var("UNRELATED_EVAL_SECRET").is_ok(),
|
||||
"credentialBinding": std::env::var("PAPERCLIP_ACPX_CREDENTIAL_BINDING").ok(),
|
||||
"credentialKeys": (["ANTHROPIC_API_KEY", "CLAUDE_CODE_OAUTH_TOKEN", "OPENAI_API_KEY", "CODEX_API_KEY", "OPENROUTER_API_KEY", "CURSOR_API_KEY", "CURSOR_AUTH_TOKEN", "COPILOT_GITHUB_TOKEN", "GITHUB_TOKEN", "GH_TOKEN"].into_iter().filter(|key| std::env::var(key).is_ok()).collect::<Vec<_>>()),
|
||||
"credentialKeys": (["ANTHROPIC_API_KEY", "CLAUDE_CODE_OAUTH_TOKEN", "OPENAI_API_KEY", "CODEX_API_KEY", "OPENROUTER_API_KEY", "GEMINI_API_KEY", "MY_PI_SERVICE_KEY", "PAPERCLIP_PI_PROVIDERS", "CURSOR_API_KEY", "CURSOR_AUTH_TOKEN", "COPILOT_GITHUB_TOKEN", "GITHUB_TOKEN", "GH_TOKEN"].into_iter().filter(|key| std::env::var(key).is_ok()).collect::<Vec<_>>()),
|
||||
}
|
||||
}),
|
||||
)?;
|
||||
|
||||
+13
-3
@@ -235,7 +235,7 @@ fn assigned_gateway_binding_reaches_qualified_sidecar_without_unrelated_secrets(
|
||||
.env("UNRELATED_EVAL_SECRET", "must-not-cross-boundary")
|
||||
.env(
|
||||
"PAPERCLIP_ACPX_CREDENTIAL_BINDING",
|
||||
"controller-session-binding",
|
||||
r#"{"schema":"paperclip.acpx_credential_binding.v1","agent":"pi","sessionId":"session-1","names":["OPENROUTER_API_KEY","GEMINI_API_KEY","MY_PI_SERVICE_KEY","PAPERCLIP_PI_PROVIDERS"]}"#,
|
||||
)
|
||||
.envs(
|
||||
[
|
||||
@@ -244,6 +244,9 @@ fn assigned_gateway_binding_reaches_qualified_sidecar_without_unrelated_secrets(
|
||||
"OPENAI_API_KEY",
|
||||
"CODEX_API_KEY",
|
||||
"OPENROUTER_API_KEY",
|
||||
"GEMINI_API_KEY",
|
||||
"MY_PI_SERVICE_KEY",
|
||||
"PAPERCLIP_PI_PROVIDERS",
|
||||
"CURSOR_API_KEY",
|
||||
"CURSOR_AUTH_TOKEN",
|
||||
"COPILOT_GITHUB_TOKEN",
|
||||
@@ -283,7 +286,12 @@ fn assigned_gateway_binding_reaches_qualified_sidecar_without_unrelated_secrets(
|
||||
let expected = match agent {
|
||||
"claude" => vec!["ANTHROPIC_API_KEY", "CLAUDE_CODE_OAUTH_TOKEN"],
|
||||
"codex" => vec!["OPENAI_API_KEY", "CODEX_API_KEY"],
|
||||
"pi" => vec!["OPENROUTER_API_KEY"],
|
||||
"pi" => vec![
|
||||
"OPENROUTER_API_KEY",
|
||||
"GEMINI_API_KEY",
|
||||
"MY_PI_SERVICE_KEY",
|
||||
"PAPERCLIP_PI_PROVIDERS",
|
||||
],
|
||||
"cursor" => vec!["CURSOR_API_KEY", "CURSOR_AUTH_TOKEN"],
|
||||
"copilot" => vec!["COPILOT_GITHUB_TOKEN"],
|
||||
_ => unreachable!(),
|
||||
@@ -292,7 +300,9 @@ fn assigned_gateway_binding_reaches_qualified_sidecar_without_unrelated_secrets(
|
||||
assert_eq!(
|
||||
response["credentialBinding"],
|
||||
if matches!(agent, "pi" | "cursor" | "copilot") {
|
||||
json!("controller-session-binding")
|
||||
json!(
|
||||
r#"{"schema":"paperclip.acpx_credential_binding.v1","agent":"pi","sessionId":"session-1","names":["OPENROUTER_API_KEY","GEMINI_API_KEY","MY_PI_SERVICE_KEY","PAPERCLIP_PI_PROVIDERS"]}"#
|
||||
)
|
||||
} else {
|
||||
serde_json::Value::Null
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user