mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 15:10:00 +08:00
## Purpose Retain the complete selected 12-version Cargo group and qualify its compatibility with Headroom. The AWS release moves its config, credential, Smithy runtime/schema and SDK dependencies together to a new coordinated compatibility line; upstream explicitly warns against upgrading only part of that line. Existing proxy credential resolution and SigV4 signing must continue to work with that coherent set. This is a compatibility-qualified grouped update. Companion updates are not individually claimed to fix a Headroom bug where upstream only added unused APIs. ## Selected versions and project relevance | Package | Selected update | Relevance and qualification | | --- | --- | --- | | tokio | 1.53.3 → 1.54.1 | Proxy HTTP/SSE/WebSocket execution and timers; includes upstream timer-handle regression revert. Local native proxy/SSE/WSS tests exercise runtime. | | aws-config | 1.12.0 → 1.13.0 | Required companion for new AWS schema/runtime compatibility line; production environment credential chain exercised with explicit fake credentials. | | aws-credential-types | 1.3.0 → 1.3.1 | Same coordinated AWS line, production credential conversion and SigV4 signing exercised. | | aws-smithy-runtime-api | 1.19.0 → 1.19.2 | Same coordinated AWS line; timeout finalizer behavior changed upstream. Local signing/wire tests do not establish SSO/STS timeout behavior. | | sha2 | 0.11.0 → 0.11.1 | Existing cache/SigV4-related payload hashing; upstream unsafe-op lint fix. Local signed payload SHA256 verified; no claimed cryptographic vulnerability fixed. | | redis | 1.7.1 → 1.8.0 | Optional multiworker CCR backend; upstream TLS error/secret redaction and subscription correctness fixes. Production backend roundtrip exercised against local RESP fixture; cluster/pubsub are not Headroom backend usage. | | tree-sitter | 0.27.0 → 0.27.1 | Code compressor parser/error recovery fixes. Reconstructed 9 samples × 8 pinned languages compare old/new node kinds, complete row/column spans, ERROR/MISSING: 72/72 identical. | | uuid | 1.28.0 → 1.29.0 | Full-group companion target; new NonNilUuid constructors are unused. Existing request-ID generation exercised through real proxy calls and both response x-request-id values parsed as UUIDv4; no invented bug/security rationale. | | crc32fast | 1.5.2 → 1.5.3 | Full-group companion target; upstream total-length API is unused. Existing Bedrock EventStream checksum/framing path exercised by streaming integration suite. | | rustls-native-certs | 0.8.4 → 0.8.5 | Native trust-store handling; avoids duplicate Unix certificate-file reads. Windows build and WSS fail-closed behavior exercised; Unix store traversal not locally exercised. | | webpki-roots | 1.0.10 → 1.0.11 | Updated bundled CA trust set (CCADB CA removals); WSS verification tests exercise existing explicit TLS configuration. No public CA endpoint contacted. | | cc | 1.8.0 → 1.10.0 | Native C/C++ dependency builds; upstream fixes MSVC archive object paths and cl.exe wrapper handling. Actual clean Windows MSVC native dependency compilation performed. | ## Maintenance and install surface The packages remain maintained by their existing upstream projects: Tokio, AWS/Smithy, RustCrypto, redis-rs, tree-sitter, uuid-rs, srijs/rust-crc32fast, rustls and rust-lang/cc-rs. Release/compare links in the original Dependabot body identify the reviewed releases; AWS authoritative release notes: https://github.com/awslabs/aws-sdk-rust/blob/main/CHANGELOG.md (October 20–30, 2026). UUID comparison confirms its change only adds NonNilUuid constructors; it is not presented as a security fix. No new package source/registry is introduced. Cargo resolves registry downloads at build time; cc executes the native compiler for existing C/C++ dependencies (tree-sitter grammars and other existing native crates). The lock update changes the transitive AWS SDK/schema/runtime family together. Existing ONNX runtime loading/model behavior is not altered by this PR. Redis is feature gated and adds runtime network only when explicitly configured. AWS credentials can normally resolve through environment, profiles, SSO/STS or metadata; qualification uses only explicit fake environment credentials, NUL config files and disabled IMDS. Normal configured proxy upstream traffic and native trust-store reads remain existing runtime surfaces. Pinned qualification compiler: Rust 1.95.0 on Windows/MSVC. Resolved proxy AWS floor is 1.94.1; core/Python/parity graph includes tree-sitter-language floor 1.90. Both already existed in the base lock, so no global rust-version change is made; inherited workspace rust-version=1.80 is not a valid full-workspace source-build promise. Fresh base/head Windows-filtered metadata comparison confirms unchanged floors: core/Python/parity1.90,proxy1.94.1,simulators1.86(ICU). These are dependency-declared effective floors, not measured lower-toolchain builds. No lower-toolchain build was attempted. ## Real behavior proof Windows, Rust1.95.0 x86_64-pc-windows-msvc, isolated worktree, dedicated CARGO_TARGET_DIR, CARGO_BUILD_JOBS=2. No actual AWS/provider credentials, profiles, cloud inference or model downloads used. - `cargo test --locked -p headroom-core -p headroom-proxy` with explicit existing x64 ONNX Runtime DLL (`ORT_DYLIB_PATH`) and `HEADROOM_OFFLINE=1`, `HF_HUB_OFFLINE=1`, `TRANSFORMERS_OFFLINE=1`: **1,659 passed, 0 failed, 3 ignored; exit 0**, across 61 test/doc-test executables. Initial run without the Windows loader path was diagnosed loader-blocked and terminated; its separate failed log is retained. - `cargo test --locked -p headroom-proxy --test integration_bedrock_invoke --test integration_bedrock_streaming --test integration_ws_tls --test integration_sse`: 23passed,0failed (8invoke,11streaming,2SSE,2WSS). - `python G:/git/headroom/.codex/dep4553-runtime.py`: built headroom-proxy.exe on ephemeral ports with compression disabled; passthrough and native Bedrock routes each return local200, both bodies byte equal; AWS environment provider loaded fake credentials and SigV4 Credential prefix/payload SHA256 checked; both generated response x-request-id headers validated UUIDv4. Synthetic wire fixture, not real AWS service emulation. - `python G:/git/headroom/.codex/dep4553-redis-wire.py`: temporary integration test calls production RedisCcrStore using redis1.8.0; local RESP fixture validates PING,miss,UTF8 payload write/read,TTL refresh and replacement; 1passed. Synthetic protocol server; supplemented by `python G:/git/headroom/.codex/dep4553-redis-real.py`: real Redis7Alpine ephemeral loopback Docker service with persistence disabled; production backend2testsPASS,including real TTLrefresh andexpiry. Owned --rmcontainer stopped automatically. TLS/cluster/failover/pubsub not tested. - Standalone canary under `.codex/dep4553-canary`: exact engine versions0.27.0 and0.27.1, same eight pinned grammars,72/72 AST snapshots identical. Historical canary source was absent; reconstructed inputs are recorded, including second distinct valid fixture per language (explicit Cfunctionpointer sample), CRLF,truncated,error,concatenated andUnicode cases. - Isolated Python3.12 env: recorder regression9tests passed; Ruff checks/format passed. Original official fixture generator reproduced KeyError(bash). Minimal3line helper fix raises ValueError, matching existing detector unsupported-language contract; all8pinned grammars remain covered. Official generator then recorded30fixtures. - Generator revealed12preexisting Python-reference fixture differences. Exact main74277d47 source extracted independently, same Python environment +same helper fix:30/30 regenerated semantic fixture objects match PR source, excluding recorded_at only. Preserve original repo fixture bytes; do not mask unrelated Python-reference drift by replacing goldens. Baseline/regenerated files and comparisons retained as artifacts. ## Remaining gates / limitations Initial broad Cargo suite was loader-blocked: source live_zone.rs documents indefinite Windows initialization without ORT_DYLIB_PATH. Controlled termination of exact owned testPID717412 produced authoritative exit1 for original session37711. Distinct corrected configuration uses existing verified x64ORT1.26.0 DLL(API24), explicit ORT_DYLIB_PATH and offline guards; corrected full core+proxy qualification completed exit0,1659passed,0failed,3ignored. This is an environment diagnosis, not a demonstrated dependency regression. Hosted checks must be rerun on the exact final remote SHA; prior shard4 red is not claimed fixed. Canonical fixture rerecord was executed and its baseline-identical semantic drift documented, not silently normalized away. No Linux/macOS build, lower MSRV build, real AWS SSO/STS/IMDS, public CA endpoint, Redis TLS/cluster/failover, production provider inference or model download was tested. No remote push, PR edit/review or merge performed by this qualification task. ## Public reproduction The committed standard-library harness reproduces the full 72-case parser comparison and launches the actual native proxy against credentialless loopback fixtures. It stores both complete AST snapshots and inputs when `--artifacts-dir` is provided. No private `.codex` artifacts are needed. Windows, from a clean checkout with Rust 1.95/MSVC and Python 3.11+: ```powershell cargo build --locked -p headroom-proxy --target-dir target/qualification python scripts/qualify_cargo_dependencies.py all --binary target/qualification/debug/headroom-proxy.exe --artifacts-dir target/qualification-proof --canary-target-dir target/qualification-canary ``` Linux/macOS use the same commands with the binary path `target/qualification/debug/headroom-proxy` (omit `.exe`). Those platforms are reproduction instructions, not platforms locally qualified here. The canary compiles standalone exact engine versions0.27.0/0.27.1 against all eight production grammar pins, so Cargo registry downloads/native compilers may be needed. Runtime checks use fake AWS credentials, platform null config files, disabled IMDS, offline model guards, compression off, and local HTTP endpoints only. The source-comment-required Python fixture rerecord is independently reproducible: ```text python -m pip install tree-sitter==0.25.2 tree-sitter-python==0.25.0 tree-sitter-javascript==0.25.0 tree-sitter-typescript==0.23.2 tree-sitter-go==0.25.0 tree-sitter-rust==0.24.2 tree-sitter-java==0.23.5 tree-sitter-c==0.24.2 tree-sitter-cpp==0.23.4 python scripts/record_code_compressor_fixtures.py ``` Use an isolated development Python environment with the project development dependencies installed. The recorder helper fix in this PR preserves its existing eight-grammar scope; unsupported detector candidates are skipped through the existing ValueError contract. Regeneration currently exposes baseline Python-reference drift as documented above; inspect semantic differences rather than replacing goldens blindly. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JerrettDavis <mxjerrett@gmail.com>
295 lines
11 KiB
Python
295 lines
11 KiB
Python
#!/usr/bin/env python3
|
|
"""Reproduce the Cargo parser canary and credentialless native proxy proof.
|
|
|
|
Standard-library-only driver. Run from any directory; Cargo uses the repository's
|
|
pinned toolchain. The parser comparison compiles two temporary standalone crates
|
|
and uses the eight exact production grammar pins. Runtime proof requires an
|
|
already-built headroom-proxy binary and never enables model compression.
|
|
"""
|
|
|
|
import argparse
|
|
import hashlib
|
|
import http.server
|
|
import json
|
|
import os
|
|
import socket
|
|
import subprocess
|
|
import tempfile
|
|
import threading
|
|
import time
|
|
import urllib.request
|
|
import uuid
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
RUST_CANARY = r"""
|
|
use serde_json::{json, Value};
|
|
fn visit(n: tree_sitter::Node, out: &mut Vec<Value>) {
|
|
out.push(json!([
|
|
n.kind(),
|
|
n.start_position().row,
|
|
n.start_position().column,
|
|
n.end_position().row,
|
|
n.end_position().column,
|
|
n.is_error(),
|
|
n.is_missing()
|
|
]));
|
|
let mut c = n.walk();
|
|
for child in n.children(&mut c) {
|
|
visit(child, out);
|
|
}
|
|
}
|
|
fn main() {
|
|
let inputs: Vec<Value> = serde_json::from_str(include_str!("../inputs.json")).unwrap();
|
|
let mut outputs = vec![];
|
|
for input in inputs {
|
|
let l = input["language"].as_str().unwrap();
|
|
let language: tree_sitter::Language = match l {
|
|
"python" => tree_sitter_python::LANGUAGE.into(),
|
|
"javascript" => tree_sitter_javascript::LANGUAGE.into(),
|
|
"typescript" => tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into(),
|
|
"go" => tree_sitter_go::LANGUAGE.into(),
|
|
"rust" => tree_sitter_rust::LANGUAGE.into(),
|
|
"java" => tree_sitter_java::LANGUAGE.into(),
|
|
"c" => tree_sitter_c::LANGUAGE.into(),
|
|
"cpp" => tree_sitter_cpp::LANGUAGE.into(),
|
|
_ => panic!(),
|
|
};
|
|
let mut p = tree_sitter::Parser::new();
|
|
p.set_language(&language).unwrap();
|
|
let tree = p.parse(input["source"].as_str().unwrap(), None).unwrap();
|
|
let mut nodes = vec![];
|
|
visit(tree.root_node(), &mut nodes);
|
|
outputs.push(json!({"language":l,"sample":input["sample"],"nodes":nodes}));
|
|
}
|
|
println!("{}", serde_json::to_string(&outputs).unwrap());
|
|
}
|
|
"""
|
|
|
|
|
|
def parser_canary(artifacts, target):
|
|
crate = artifacts / "parser-canary"
|
|
(crate / "src").mkdir(parents=True, exist_ok=True)
|
|
fixtures = {}
|
|
for path in sorted((ROOT / "tests/parity/fixtures/code_aware_compressor").glob("*.json")):
|
|
fixture = json.loads(path.read_text(encoding="utf-8"))
|
|
sources = fixtures.setdefault(fixture["output"]["language"], [])
|
|
if fixture["input"] not in sources:
|
|
sources.append(fixture["input"])
|
|
fixtures["c"] = [
|
|
"struct Point { int x; int y; };\nint main(void) { struct Point p={1,2}; return p.x; }\n",
|
|
"int apply(int (*fn)(int), int x) { return fn(x); }\nint square(int x) { return x*x; }\nint main(void) { return apply(square, 4); }\n",
|
|
]
|
|
inputs = []
|
|
for language in ("python", "javascript", "typescript", "go", "rust", "java", "c", "cpp"):
|
|
original, second = fixtures[language][:2]
|
|
samples = [
|
|
original,
|
|
"",
|
|
original + "\n",
|
|
second,
|
|
original.replace("\n", "\r\n"),
|
|
original[: len(original) // 2],
|
|
original + "\n} ) ]",
|
|
original + "\n" + original,
|
|
original.replace("Processor", "Caf\u00e9")
|
|
if "Processor" in original
|
|
else original + "\n\u03bb\u4e2d\U0001f600",
|
|
]
|
|
inputs.extend(
|
|
{"language": language, "sample": i + 1, "source": source}
|
|
for i, source in enumerate(samples)
|
|
)
|
|
(crate / "inputs.json").write_text(
|
|
json.dumps(inputs, ensure_ascii=False), encoding="utf-8", newline="\n"
|
|
)
|
|
(crate / "src/main.rs").write_text(RUST_CANARY, encoding="utf-8", newline="\n")
|
|
manifest = """[package]
|
|
name="headroom-parser-qualification"
|
|
version="0.0.0"
|
|
edition="2021"
|
|
[workspace]
|
|
[dependencies]
|
|
tree-sitter="=VERSION"
|
|
serde_json="=1.0.154"
|
|
tree-sitter-python="=0.25.0"
|
|
tree-sitter-javascript="=0.25.0"
|
|
tree-sitter-typescript="=0.23.2"
|
|
tree-sitter-go="=0.25.0"
|
|
tree-sitter-rust="=0.24.2"
|
|
tree-sitter-java="=0.23.5"
|
|
tree-sitter-c="=0.24.2"
|
|
tree-sitter-cpp="=0.23.4"
|
|
"""
|
|
outputs = []
|
|
for version in ("0.27.0", "0.27.1"):
|
|
(crate / "Cargo.toml").write_text(
|
|
manifest.replace("VERSION", version), encoding="utf-8", newline="\n"
|
|
)
|
|
result = subprocess.run(
|
|
[
|
|
"cargo",
|
|
"run",
|
|
"--quiet",
|
|
"--manifest-path",
|
|
str(crate / "Cargo.toml"),
|
|
"--target-dir",
|
|
str(target),
|
|
],
|
|
cwd=ROOT,
|
|
capture_output=True,
|
|
text=True,
|
|
check=True,
|
|
)
|
|
(artifacts / f"parser-{version}.json").write_text(
|
|
result.stdout, encoding="utf-8", newline="\n"
|
|
)
|
|
outputs.append(json.loads(result.stdout))
|
|
assert len(outputs[0]) == len(outputs[1]) == 72
|
|
for before, after in zip(*outputs, strict=True):
|
|
assert before == after, (before["language"], before["sample"])
|
|
print("AST", before["language"], before["sample"], "PASS", len(before["nodes"]), "nodes")
|
|
print(
|
|
"PASS 72/72 reconstructed samples: 8 pinned languages x 9 samples; historical corpus unavailable"
|
|
)
|
|
|
|
|
|
def native_runtime(binary, artifacts):
|
|
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
|
seen = []
|
|
|
|
class Handler(http.server.BaseHTTPRequestHandler):
|
|
def do_POST(self):
|
|
body = b""
|
|
if self.headers.get("Transfer-Encoding", "").lower() == "chunked":
|
|
while True:
|
|
size = int(self.rfile.readline().strip().split(b";")[0], 16)
|
|
if not size:
|
|
self.rfile.readline()
|
|
break
|
|
body += self.rfile.read(size)
|
|
self.rfile.read(2)
|
|
else:
|
|
body = self.rfile.read(int(self.headers.get("Content-Length", "0")))
|
|
seen.append((self.path, dict(self.headers), body))
|
|
answer = b'{"content":[{"type":"text","text":"fixture-ok"}],"usage":{"input_tokens":3,"output_tokens":2}}'
|
|
self.send_response(200)
|
|
self.send_header("Content-Type", "application/json")
|
|
self.send_header("Content-Length", str(len(answer)))
|
|
self.end_headers()
|
|
self.wfile.write(answer)
|
|
|
|
def log_message(self, *args):
|
|
pass
|
|
|
|
server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Handler)
|
|
threading.Thread(target=server.serve_forever, daemon=True).start()
|
|
with socket.socket() as s:
|
|
s.bind(("127.0.0.1", 0))
|
|
port = s.getsockname()[1]
|
|
base = f"http://127.0.0.1:{server.server_port}"
|
|
env = {k: v for k, v in os.environ.items() if not k.startswith(("AWS_", "HEADROOM_PROXY_"))}
|
|
env.update(
|
|
AWS_ACCESS_KEY_ID="AKIDEXAMPLE",
|
|
AWS_SECRET_ACCESS_KEY="fake-local-test-secret",
|
|
AWS_EC2_METADATA_DISABLED="true",
|
|
AWS_CONFIG_FILE=os.devnull,
|
|
AWS_SHARED_CREDENTIALS_FILE=os.devnull,
|
|
AWS_REGION="us-east-1",
|
|
HEADROOM_OFFLINE="1",
|
|
HF_HUB_OFFLINE="1",
|
|
NO_PROXY="127.0.0.1,localhost",
|
|
TRANSFORMERS_OFFLINE="1",
|
|
)
|
|
log = open(artifacts / "runtime-proxy.log", "w", encoding="utf-8", newline="\n")
|
|
proc = subprocess.Popen(
|
|
[
|
|
str(binary),
|
|
"--listen",
|
|
f"127.0.0.1:{port}",
|
|
"--upstream",
|
|
base,
|
|
"--enable-bedrock-native",
|
|
"true",
|
|
"--bedrock-endpoint",
|
|
base,
|
|
],
|
|
env=env,
|
|
stdout=log,
|
|
stderr=subprocess.STDOUT,
|
|
)
|
|
try:
|
|
for _ in range(150):
|
|
if proc.poll() is not None:
|
|
raise RuntimeError(f"proxy exited {proc.returncode}")
|
|
try:
|
|
with socket.create_connection(("127.0.0.1", port), timeout=0.1):
|
|
break
|
|
except OSError:
|
|
time.sleep(0.1)
|
|
payload = b'{"anthropic_version":"bedrock-2023-05-31","max_tokens":8,"messages":[{"role":"user","content":"local fixture"}]}'
|
|
for path in ["/v1/messages", "/model/anthropic.claude-3-haiku-20240307-v1:0/invoke"]:
|
|
with opener.open(
|
|
urllib.request.Request(
|
|
f"http://127.0.0.1:{port}" + path,
|
|
data=payload,
|
|
headers={"Content-Type": "application/json"},
|
|
),
|
|
timeout=15,
|
|
) as response:
|
|
answer = json.load(response)
|
|
assert answer["content"][0]["text"] == "fixture-ok"
|
|
rid = uuid.UUID(response.headers["x-request-id"])
|
|
assert rid.version == 4
|
|
print(path, response.status, "UUIDv4", str(rid))
|
|
assert len(seen) == 2, seen
|
|
assert all(body == payload for _, _, body in seen)
|
|
headers = {k.lower(): v for k, v in seen[-1][1].items()}
|
|
assert headers["authorization"].startswith("AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/")
|
|
assert headers["x-amz-content-sha256"] == hashlib.sha256(payload).hexdigest()
|
|
print(
|
|
"PASS: built binary passthrough + AWS environment provider/SigV4 local wire proof; body byte-equal; payload hash verified. No real AWS/SDK service response emulation."
|
|
)
|
|
finally:
|
|
try:
|
|
if proc.poll() is None:
|
|
proc.terminate()
|
|
try:
|
|
proc.wait(timeout=20)
|
|
except subprocess.TimeoutExpired:
|
|
proc.kill()
|
|
proc.wait(timeout=20)
|
|
finally:
|
|
try:
|
|
server.shutdown()
|
|
finally:
|
|
try:
|
|
server.server_close()
|
|
finally:
|
|
log.close()
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("mode", choices=("canary", "runtime", "all"))
|
|
parser.add_argument("--binary", type=Path, help="built headroom-proxy executable")
|
|
parser.add_argument("--artifacts-dir", type=Path)
|
|
parser.add_argument(
|
|
"--canary-target-dir", type=Path, default=ROOT / "target/cargo-qualification"
|
|
)
|
|
args = parser.parse_args()
|
|
if args.mode in ("runtime", "all") and not args.binary:
|
|
parser.error("--binary is required for runtime/all")
|
|
with tempfile.TemporaryDirectory(prefix="headroom-cargo-proof-") as temporary:
|
|
artifacts = (args.artifacts_dir or Path(temporary)).resolve()
|
|
artifacts.mkdir(parents=True, exist_ok=True)
|
|
if args.mode in ("canary", "all"):
|
|
parser_canary(artifacts, args.canary_target_dir.resolve())
|
|
if args.mode in ("runtime", "all"):
|
|
native_runtime(args.binary.resolve(strict=True), artifacts)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|