CHAT_OUTPUT_BEGIN
COMMAND_ID=HOMELAB-READER-V3-STORAGE-CONTRACT-AUDIT-375
STATUS=OK
RC=0
HOST=pve01
MODE=read-only
COMPONENT=cluster-audit
REFERENCE_REGISTER_CHECK=OK
REFERENCE_SHA256=5763f2f8edc75fcf6f3951f8c95896d1cc112ceccb6cf5b64a383f540a4deb8e
ERROR_REGISTER_CHECK=OK
ERROR_REGISTER_SHA256=08b3a769b8e38eaa1acec915352fb328180d70caa7ff6cd9d1ec0da426262752
COMMAND_SHA256=7a9dc5ecf6ec239bf61ccf2a67f6b3238f06106fe9ff6ff7c5442f76dd566e20
DUPLICATE_FAILED_COMMAND_BLOCKED=false
EXECUTION_STARTED=true
CHANGES_MADE=false
SANITIZED=yes
SECRETS_INCLUDED=no
PRIVATE_ADDRESSES_INCLUDED=no
RAW_EVIDENCE_SHA256=520e76d1ea9c69ce029685bd7089a4d2b361287d3133004063ec0fd5adc97ee3
SANITIZED_OUTPUT_SHA256=3bbc00cf03cf0b7088f1551454d01bf5f982791084f4c03918afecbe2986f1e9
OUTPUT_BEGIN
DETAIL=READER_SHA256=092780e76ff18dfe2920c51f8b97dd09d194fd6cbdb59c3755c9fbf6530f3536
DETAIL=LINKED_SHA256=efa9fce3c768e6e0650903ca14fe4b6d5319d57f20ec87c465a4a00cb300d4e0
DETAIL=SOURCE_SYNTAX_AND_INTEGRITY=PASS
DETAIL=READER_STORAGE_SOURCE_BEGIN
DETAIL=READER_LINE=1|#!/usr/bin/python3
DETAIL=READER_LINE=2|import hashlib
DETAIL=READER_LINE=3|import http.server
DETAIL=READER_LINE=4|import json
DETAIL=READER_LINE=5|import os
DETAIL=READER_LINE=6|import pathlib
DETAIL=READER_LINE=7|import re
DETAIL=READER_LINE=8|import sys
DETAIL=READER_LINE=9|
DETAIL=READER_LINE=10|ROOT=pathlib.Path("/var/lib/homelab-reader-v3")
DETAIL=READER_LINE=11|MANIFEST=ROOT/"manifest.json"
DETAIL=READER_LINE=12|RESULTS=ROOT/"results"
DETAIL=READER_LINE=13|CAPABILITY=os.environ["HOMELAB_READER_CAPABILITY"]
DETAIL=READER_LINE=14|PORT=int(os.environ.get("HOMELAB_READER_PORT","18788"))
DETAIL=READER_LINE=15|RESULT_RE=re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]{0,127}-[0-9a-f]{64}\.txt$")
DETAIL=READER_LINE=16|
DETAIL=READER_LINE=17|class Handler(http.server.BaseHTTPRequestHandler):
DETAIL=READER_LINE=18|    server_version="HomelabReader/3"
DETAIL=READER_LINE=19|
DETAIL=READER_LINE=20|    def log_message(self,fmt,*args):
DETAIL=READER_LINE=21|        sys.stderr.write("%s - %s\n"%(self.address_string(),fmt%args))
DETAIL=READER_LINE=22|
DETAIL=READER_LINE=23|    def reply(self,status,content_type,payload,etag="",include_body=True):
DETAIL=READER_LINE=24|        self.send_response(status)
DETAIL=READER_LINE=25|        self.send_header("Content-Type",content_type)
DETAIL=READER_LINE=26|        self.send_header("Content-Length",str(len(payload)))
DETAIL=READER_LINE=27|        self.send_header("Cache-Control","no-store, no-cache, must-revalidate, max-age=0")
DETAIL=READER_LINE=28|        self.send_header("Surrogate-Control","no-store")
DETAIL=READER_LINE=29|        self.send_header("Pragma","no-cache")
DETAIL=READER_LINE=30|        self.send_header("Expires","0")
DETAIL=READER_LINE=31|        self.send_header("X-Robots-Tag","noindex, nofollow, noarchive")
DETAIL=READER_LINE=32|        if etag:
DETAIL=READER_LINE=33|            self.send_header("ETag",chr(34)+etag+chr(34))
DETAIL=READER_LINE=34|            self.send_header("X-Homelab-Generation",etag)
DETAIL=READER_LINE=35|        self.end_headers()
DETAIL=READER_LINE=36|        if include_body:
DETAIL=READER_LINE=37|            self.wfile.write(payload)
DETAIL=READER_LINE=38|
DETAIL=READER_LINE=39|    def do_HEAD(self):
DETAIL=READER_LINE=40|        self.handle_reader(False)
DETAIL=READER_LINE=41|
DETAIL=READER_LINE=42|    def do_GET(self):
DETAIL=READER_LINE=43|        self.handle_reader(True)
DETAIL=READER_LINE=44|
DETAIL=READER_LINE=45|    def handle_reader(self,include_body):
DETAIL=READER_LINE=46|        request_path=self.path.split("?",1)[0]
DETAIL=READER_LINE=47|        prefix="/"+CAPABILITY+"/"
DETAIL=READER_LINE=48|        if not request_path.startswith(prefix):
DETAIL=READER_LINE=49|            self.reply(404,"text/plain; charset=utf-8",b"not found\n",include_body=include_body)
DETAIL=READER_LINE=50|            return
DETAIL=READER_LINE=51|
DETAIL=READER_LINE=52|        relative=request_path[len(prefix):]
DETAIL=READER_LINE=53|
DETAIL=READER_LINE=54|        if relative=="health":
DETAIL=READER_LINE=55|            self.reply(200,"application/json; charset=utf-8",b"{\"status\":\"ok\",\"version\":3}\n","health-v3",include_body)
DETAIL=READER_LINE=56|            return
DETAIL=READER_LINE=57|
DETAIL=READER_LINE=58|        if relative=="feed":
DETAIL=READER_LINE=59|            try:
DETAIL=READER_LINE=60|                payload=MANIFEST.read_bytes()
DETAIL=READER_LINE=61|                document=json.loads(payload.decode("utf-8"))
DETAIL=READER_LINE=62|                generation=str(document.get("generation","0"))
DETAIL=READER_LINE=63|                self.reply(200,"application/json; charset=utf-8",payload,generation,include_body)
DETAIL=READER_LINE=64|            except Exception:
DETAIL=READER_LINE=65|                self.reply(500,"text/plain; charset=utf-8",b"reader error\n",include_body=include_body)
DETAIL=READER_LINE=66|            return
DETAIL=READER_LINE=67|
DETAIL=READER_LINE=68|        if relative.startswith("results/"):
DETAIL=READER_LINE=69|            name=relative[len("results/"):]
DETAIL=READER_LINE=70|            target=RESULTS/name
DETAIL=READER_LINE=71|            if not RESULT_RE.fullmatch(name) or not target.is_file():
DETAIL=READER_LINE=72|                self.reply(404,"text/plain; charset=utf-8",b"not found\n",include_body=include_body)
DETAIL=READER_LINE=73|                return
DETAIL=READER_LINE=74|            try:
DETAIL=READER_LINE=75|                payload=target.read_bytes()
DETAIL=READER_LINE=76|                digest=name.rsplit("-",1)[1][:-4]
DETAIL=READER_LINE=77|                if hashlib.sha256(payload).hexdigest()!=digest:
DETAIL=READER_LINE=78|                    self.reply(500,"text/plain; charset=utf-8",b"integrity error\n",include_body=include_body)
DETAIL=READER_LINE=79|                    return
DETAIL=READER_LINE=80|                self.reply(200,"text/plain; charset=utf-8",payload,digest,include_body)
DETAIL=READER_LINE=81|            except Exception:
DETAIL=READER_LINE=82|                self.reply(500,"text/plain; charset=utf-8",b"reader error\n",include_body=include_body)
DETAIL=READER_LINE=83|            return
DETAIL=READER_LINE=84|
DETAIL=READER_LINE=85|        self.reply(404,"text/plain; charset=utf-8",b"not found\n",include_body=include_body)
DETAIL=READER_LINE=86|
DETAIL=READER_LINE=87|class Server(http.server.ThreadingHTTPServer):
DETAIL=READER_LINE=88|    allow_reuse_address=True
DETAIL=READER_LINE=89|
DETAIL=READER_LINE=90|Server(("[PRIVATE_IP]",PORT),Handler).serve_forever()
DETAIL=READER_STORAGE_SOURCE_END
DETAIL=LINKED_SOURCE_BEGIN
DETAIL=LINKED_LINE=1|#!/usr/bin/env bash
DETAIL=LINKED_LINE=2|set -o pipefail
DETAIL=LINKED_LINE=3|tmp=$(/usr/bin/mktemp)
DETAIL=LINKED_LINE=4|trap '/usr/bin/rm -f "$tmp"' EXIT
DETAIL=LINKED_LINE=5|
DETAIL=LINKED_LINE=6|/usr/local/sbin/homelab-chat-run "$@" 2>&1 | /usr/bin/tee "$tmp"
DETAIL=LINKED_LINE=7|rc=${PIPESTATUS[0]}
DETAIL=LINKED_LINE=8|
DETAIL=LINKED_LINE=9|cid=$(/usr/bin/sed -n "s/^COMMAND_ID=//p" "$tmp" | /usr/bin/tail -n 1)
DETAIL=LINKED_LINE=10|sha=$(/usr/bin/sed -n "s/^COMMIT_SHA=//p" "$tmp" | /usr/bin/tail -n 1)
DETAIL=LINKED_LINE=11|raw=$(/usr/bin/sed -n "s/^LOCAL_RAW_FILE=//p" "$tmp" | /usr/bin/tail -n 1)
DETAIL=LINKED_LINE=12|
DETAIL=LINKED_LINE=13|if [[ "$cid" =~ ^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$ && "$sha" =~ ^[0-9a-f]{40}$ ]]; then
DETAIL=LINKED_LINE=14|    /usr/bin/printf "COMMIT_URL=https://git.gram1.ru/homelab-admin/homelab-public-context/commit/%s\n" "$sha"
DETAIL=LINKED_LINE=15|    /usr/bin/printf "IMMUTABLE_RESULT_URL=https://git.gram1.ru/homelab-admin/homelab-public-context/raw/commit/%s/runtime/history/%s.txt\n" "$sha" "$cid"
DETAIL=LINKED_LINE=16|fi
DETAIL=LINKED_LINE=17|
DETAIL=LINKED_LINE=18|/usr/bin/printf "FAILURE_DIAGNOSTIC_BEGIN\n"
DETAIL=LINKED_LINE=19|if [[ -n "$raw" && -r "$raw" ]]; then
DETAIL=LINKED_LINE=20|    /usr/bin/grep -Ei '^(DECISION|DETAIL|FAILURE_REASON|ERROR_CODE|SOURCE_DECISION|NGINX_[A-Z0-9_]*|READER_[A-Z0-9_]*|RESULT_FEED_URL|PUBLIC_HEALTH_URL|HTTPS_[A-Z0-9_]*|LOCAL_[A-Z0-9_]*|CHANGES_MADE)=|Traceback|RuntimeError|SystemExit|FileNotFoundError|PermissionError|command not found|No such file or directory|Connection refused|failed|invalid|missing' "$raw" | /usr/bin/tail -n 100 || true
DETAIL=LINKED_LINE=21|fi
DETAIL=LINKED_LINE=22|/usr/bin/printf "FAILURE_DIAGNOSTIC_END\n"
DETAIL=LINKED_LINE=23|
DETAIL=LINKED_LINE=24|exit "$rc"
DETAIL=LINKED_SOURCE_END
Result=success
ExecMainStatus=0
ExecStart={ path=/usr/bin/python3 ; argv[]=/usr/bin/python3 -B /usr/local/sbin/homelab-reader-server-v3 ; ignore_errors=no ; start_time=[Thu 2026-07-23 16:20:39 MSK] ; stop_time=[n/a] ; pid=1247 ; code=(null) ; status=0/0 }
LoadState=loaded
ActiveState=active
SubState=running
FragmentPath=/etc/systemd/system/homelab-reader-v3.service
DETAIL=PUBLIC_READER_ROUTE=feed|HTTP_STATUS=200
DETAIL=PUBLIC_READER_ROUTE=results/HOMELAB-READER-V3-FEED-CONTRACT-AUDIT-374|HTTP_STATUS=404
DETAIL=PUBLIC_READER_ROUTE=results/HOMELAB-READER-V3-FEED-CONTRACT-AUDIT-374.txt|HTTP_STATUS=404
DETAIL=READER_V3_STORAGE_CONTRACT_AUDIT=PASS
CHANGES_MADE=NO

OUTPUT_END
CHAT_OUTPUT_END
