Repository navigation
[FD-5916] feat(agents): the Codex image follows the env's clock #765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ae1d4be
eea933c
608a93d
182cef0
bce00d4
84381b8
56dac45
c726743
5e8c756
3b6f499
cecc686
afe55b4
d523a6e
ac0a39e
c8ed6e1
b5d3b4b
25af21a
7216c7c
fc3134b
f8bd9ff
f9af1b6
43fdb97
8bf8e4c
810f42e
686fdf1
9d7d6c0
1ff90bd
ca97b37
0875e06
bb4f07f
f228c9e
a3f9e34
3c60fda
dd8de29
150c563
cc3ff73
655614e
84ca228
aed27ee
2cea6f9
1837705
b605046
a6f3720
b47867b
9eff419
ff48a8f
155ef84
ef0d8de
716f5fc
96ad61c
158f548
0a90ec9
d864a99
764a13c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| ; Root's supervisord (start-agent, FD-5916): the clock follower and the egress proxy, each as its own user, on real | ||
| ; time, and the A2A server as the agent's user. The server starts with the real-time marker, which agent-env's | ||
| ; libfaketime takes out of its environment, so the server's own records keep real timestamps and everything it starts, | ||
| ; the CLI and the model's commands, reads the env's time. Its socket and logs are root's alone, so the agent's user can | ||
| ; neither stop nor restart any of them. The follower follows nothing until the server writes its config, which | ||
| ; sync_env_clock has it do, then picks it up within a quarter second. | ||
| [supervisord] | ||
| nodaemon=true | ||
| user=root | ||
| logfile=/var/log/agentenv-root/supervisord.log | ||
| pidfile=/run/agentenv-root/supervisord.pid | ||
| childlogdir=/var/log/agentenv-root | ||
|
|
||
| [unix_http_server] | ||
| file=/run/agentenv-root/supervisor.sock | ||
| chmod=0700 | ||
|
|
||
| [rpcinterface:supervisor] | ||
| supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | ||
|
|
||
| [supervisorctl] | ||
| serverurl=unix:///run/agentenv-root/supervisor.sock | ||
|
|
||
| [program:clock] | ||
| command=/usr/local/bin/python3 -I /usr/local/lib/agentenv-clock/clock-follower | ||
| user=agentenv-clock | ||
| directory=/ | ||
| priority=3 | ||
| autorestart=true | ||
| startsecs=1 | ||
| startretries=1000 | ||
| redirect_stderr=true | ||
| stdout_logfile=/var/log/agentenv-root/clock.log | ||
| environment=HOME="/nonexistent",USER="agentenv-clock",LOGNAME="agentenv-clock" | ||
|
|
||
| [program:egress] | ||
| command=/usr/local/lib/agentenv-egress/egress serve | ||
| user=agentenv-egress | ||
| directory=/ | ||
| priority=3 | ||
| autorestart=true | ||
| startsecs=1 | ||
| startretries=1000 | ||
| redirect_stderr=true | ||
| stdout_logfile=/var/log/agentenv-root/egress.log | ||
| environment=HOME="/nonexistent",USER="agentenv-egress",LOGNAME="agentenv-egress",AGENTENV_EGRESS_PRIVATE="allow" | ||
|
|
||
| ; uvicorn itself, not entrypoint.sh: the marker holds for the process it's given to alone, and a shell that execs | ||
| ; uvicorn would hand uvicorn an environment without it. | ||
| [program:agent] | ||
| command=/usr/local/bin/python3 -m uvicorn a2a_server:app --host 0.0.0.0 --port %(ENV_A2A_PORT)s --timeout-graceful-shutdown 5 | ||
| user=agent | ||
| directory=/app | ||
| priority=10 | ||
| autorestart=true | ||
| stopasgroup=true | ||
| killasgroup=true | ||
| stopwaitsecs=30 | ||
| redirect_stderr=true | ||
| stdout_logfile=/dev/stdout | ||
| stdout_logfile_maxbytes=0 | ||
| environment=HOME="/home/agent",USER="agent",LOGNAME="agent",AGENTENV_REAL_TIME="1",AGENTENV_EGRESS_PROXY="http://127.0.0.1:3128",NODE_EXTRA_CA_CERTS="/etc/agentenv/ca.pem",SSL_CERT_FILE="/etc/agentenv/ca-bundle.pem",REQUESTS_CA_BUNDLE="/etc/agentenv/ca-bundle.pem" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # What this image's build context takes from agent-env's own sources, at the name its Dockerfile copies it from: one | ||
| # copy of each, shared with the other images that take it (utils/docker/context.py). Paths are under src/agent_env. | ||
| clock = "utils/faketime_clock" | ||
| egress = "utils/egress_proxy" | ||
| agent_clock = "utils/agent_clock" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #!/bin/sh | ||
| # The image's start (FD-5916). As root, it makes what the agent's user must not touch, the clock page and file (the | ||
| # clock user's from their first byte) and the egress proxy's CA (its key the egress user's alone, trusted in the | ||
| # system store, agent-env's trust files and every certifi bundle), then starts root's supervisord (root.conf), which | ||
| # runs the clock follower and the egress proxy, each as its own user on real time, and the A2A server as the agent's | ||
| # user on real time, everything it starts reading the env's time from the page. Until sync_env_clock has the agent | ||
| # follow a clock, the page holds real time and the proxy relays TLS untouched. Started as another user, the image runs | ||
| # the A2A server alone, as before, on real time. | ||
| set -eu | ||
| if [ "$(id -u)" != 0 ]; then | ||
| exec /opt/agent/entrypoint.sh | ||
| fi | ||
| install -d -o root -g root -m 0700 /var/log/agentenv-root /run/agentenv-root | ||
| install -d -o agentenv-clock -g agentenv-clock -m 0755 /run/agentenv-clock | ||
| python3 -I /usr/local/lib/agentenv-clock/clockpage.py create agentenv-clock | ||
| AGENTENV_SESSION_USER=agent AGENTENV_EGRESS_NSS=off \ | ||
| /usr/local/lib/agentenv-egress/egress boot > /var/log/agentenv-root/egress-boot.log 2>&1 \ | ||
| || { cat /var/log/agentenv-root/egress-boot.log >&2; echo "the egress proxy's boot failed" >&2; exit 2; } | ||
| # A provider's own CA bundle stays trusted: Sail, for one, points SSL_CERT_FILE and the like at the bundle it signs | ||
| # model requests under, and root.conf points the server's trust at agent-env's bundles instead, so the provider's goes | ||
| # into them, and into the egress proxy's roots, which carry those requests once the clock is armed. | ||
| for bundle in "${SSL_CERT_FILE:-}" "${REQUESTS_CA_BUNDLE:-}" "${NODE_EXTRA_CA_CERTS:-}" "${CURL_CA_BUNDLE:-}"; do | ||
| case "$bundle" in ""|/etc/agentenv/*) continue ;; esac | ||
| [ -r "$bundle" ] || continue | ||
| for target in /etc/agentenv/ca-bundle.pem /etc/agentenv/ca.pem /usr/local/lib/agentenv-egress/roots.pem; do | ||
| grep -qxF "# agentenv: $bundle" "$target" 2>/dev/null && continue | ||
| { printf '\n# agentenv: %s\n' "$bundle"; cat "$bundle"; } >> "$target" | ||
| done | ||
| done | ||
| exec supervisord -c /etc/agentenv/root.conf |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ import ( | |
| "sort" | ||
| "strings" | ||
| "sync" | ||
| "time" | ||
| ) | ||
|
|
||
| // The longest common name X.509 allows (ub-common-name). | ||
|
|
@@ -85,7 +86,7 @@ func (l *Leaves) For(host string, sans []string, trusted bool) (*tls.Certificate | |
| template := &x509.Certificate{ | ||
| SerialNumber: serial(), | ||
| Subject: pkix.Name{CommonName: truncate(host, commonNameLimit)}, | ||
| NotBefore: by.cert.NotBefore.Add(LeafInset), | ||
| NotBefore: latest(by.cert.NotBefore.Add(LeafInset), LeafFrom), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/agent_env/utils/egress_proxy/leaves.go
Line: 89
Comment:
**Historical clocks break HTTPS.** This changes every shared proxy certificate to start in 1970, not just certificates used by Codex. A computer or Claude Code agent following a supported date such as 1960 now receives a certificate that is not yet valid when it opens a live HTTPS site. Those clients previously accepted the certificate starting in 1950. Keep the earlier window for existing clients rather than applying Codex’s date restriction to every image.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. |
||
| NotAfter: by.cert.NotAfter.Add(-LeafInset), | ||
| KeyUsage: x509.KeyUsageDigitalSignature, | ||
| ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, | ||
|
|
@@ -140,6 +141,13 @@ func mintCA(name string) (signer, error) { | |
| return signer{cert: cert, key: key}, nil | ||
| } | ||
|
|
||
| func latest(a, b time.Time) time.Time { | ||
| if a.After(b) { | ||
| return a | ||
| } | ||
| return b | ||
| } | ||
|
|
||
| func parseSigner(certPEM, keyPEM []byte) (signer, error) { | ||
| block, _ := pem.Decode(certPEM) | ||
| if block == nil { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.