Files
mdella 1c42e913a8 feat: monky-deployd v0.1.0 — pull agent over the mesh (ADR-0028)
Stdlib-only Python 3.12 agent for docker VMs and laptops: flock → checkin
(bearer = the agent's OpenBao token, bootstrapped from the install kit's
jwt-tenancy deploy grant) → action apply|none|down → bundle (sha256
verified) → refusal checks (unresolved ${VAR} names only, manifest paths
pinned to monky/data/<env>/see/, privileged/host-network, rollback, disk
need×1.5+headroom) → lease → POST /v1/auth/jwt-tenancy/login → KV reads →
.env 0600 → promote → compose pull/up → wait healthy → report; finally
renew-self / re-lease before max TTL, scrub. Exit 0/75/78/1. Redactor log
filter. Transports sdk (openziti) / proxy (ziti tunnel proxy 18443/18200) /
system. Laptop mode.

Packaging: hardened oneshot + 60 s timer + proxy unit, nfpm .deb with
/opt/monky-deployd/venv, install.sh for Ubuntu 26.04 (Gitea release
download, enrol, ACLs, bootstrap from stdin), ansible role skeleton for
osg1-07. CI: lint/test on every change; wheel (openziti on ubuntu:26.04) and
package (nfpm) allow_failure until runner egress is proven; GitLab release +
release:gitea on v* tags. Docs: README, PROTOCOL, OPERATIONS, CHANGELOG,
CLAUDE/AGENTS.

Divergence noted: monky-tenancy main (MR !15) still ships the AppRole lease
and kit; this agent implements the plan's Gate 1 RESULT (login_jwt, no
unwrap) and refuses an AppRole lease loudly (LEASE_SHAPE).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KLB7jieMNRkTsJ2epr4Ds1
2026-09-05 08:01:36 +00:00

69 lines
2.1 KiB
Python
Executable File

#!/usr/bin/env python3
"""Fake `docker` for the hermetic tests. Records every invocation to $FAKE_DOCKER_LOG (one JSON
line per call) and answers from $FAKE_DOCKER_STATE (a JSON file the test writes):
{"ps": [{"Name": "see", "State": "running", "Health": "healthy"}], # compose ps output
"fail": ["pull"], # sub-commands that must exit 1
"free_root": "/tmp"} # DockerRootDir for `docker info`
"""
import json
import os
import sys
def main() -> int:
argv = sys.argv[1:]
state = {}
sp = os.environ.get("FAKE_DOCKER_STATE")
if sp and os.path.exists(sp):
with open(sp) as fh:
state = json.load(fh)
lp = os.environ.get("FAKE_DOCKER_LOG")
if lp:
with open(lp, "a") as fh:
fh.write(json.dumps({"argv": argv, "cwd": os.getcwd()}) + "\n")
fail = set(state.get("fail", []))
if argv[:1] == ["version"]:
print("28.3.0")
return 0
if argv[:1] == ["info"]:
print(state.get("free_root", "/"))
return 0
if argv[:2] == ["image", "prune"]:
return 0
if argv[:1] == ["compose"]:
# strip global compose flags
rest = argv[1:]
while rest and rest[0].startswith("--"):
rest = rest[2:]
sub = rest[0] if rest else ""
if sub == "version":
print("2.32.0")
return 0
if sub in fail:
print(f"fake docker: {sub} failed", file=sys.stderr)
return 1
if sub == "ps":
for row in state.get("ps", []):
print(json.dumps(row))
return 0
if sub == "logs":
print("fake compose logs")
return 0
if sub == "up" and state.get("env_file_check"):
# prove the .env is complete and 0600
d = os.getcwd()
env = os.path.join(d, ".env")
st = os.stat(env)
if st.st_mode & 0o077:
print("fake docker: .env is not 0600", file=sys.stderr)
return 1
return 0
print(f"fake docker: unknown {argv}", file=sys.stderr)
return 2
if __name__ == "__main__":
sys.exit(main())