CHAT_OUTPUT_BEGIN
COMMAND_ID=RESULT-ACCESS-WRAPPER-RC-PROBE-VERIFY-20260730T135853Z
STATUS=OK
RC=0
HOST=pve01
MODE=verify
COMPONENT=result-access
REFERENCE_REGISTER_CHECK=OK
REFERENCE_SHA256=5763f2f8edc75fcf6f3951f8c95896d1cc112ceccb6cf5b64a383f540a4deb8e
ERROR_REGISTER_CHECK=OK
ERROR_REGISTER_SHA256=24934a2c7fa5c26f6e828583c4aefac7f143b40c0171736ed7571e617d55ab83
COMMAND_SHA256=d972e48ba4d31ef6c135735ef70c76536db3ab6036607f4998f1c0602c327df7
DUPLICATE_FAILED_COMMAND_BLOCKED=false
EXECUTION_STARTED=true
CHANGE_DECLARED=false
RESULT_CONTRACT_VALID=true
RESULT_CONTRACT_STATUS=NOT_APPLICABLE
RESULT_CONTRACT_ERROR=NONE
COMMAND_RC=0
CHANGES_MADE=false
ROLLBACK_STARTED=false
ROLLBACK_RESTORED=null
MUTATION_OUTCOME=NO_MUTATION
SANITIZED=yes
SECRETS_INCLUDED=no
PRIVATE_ADDRESSES_INCLUDED=no
RAW_EVIDENCE_SHA256=7a8b5863ae4b506c137f3a138202fec09883c09d1faefd86e6e2f2bd66a28afe
SANITIZED_OUTPUT_SHA256=a83fd84368390478158381fbd7bf0f55681272fc3a93ea548d9ca08abb513ec9
OUTPUT_BEGIN
{"changes_made":false,"command_id":"RESULT-ACCESS-WRAPPER-RC-PROBE-VERIFY-20260730T135853Z","command_rc":0,"errors":[],"evidence":{"adapter_source":{"exists":true,"line_count":2972,"matches":[{"context":"1377:         return None\n1378: \n1379:     evidence_sha256 = evidence.get(\"sha256\")\n1380:     if (\n1381:         not isinstance(evidence_sha256, str)\n1382:         or SHA256_RE.fullmatch(evidence_sha256)\n1383:         is None\n1384:     ):\n1385:         evidence_sha256 = None\n1386: \n1387:     runner_rc = execution.get(\"runner_rc\")\n1388:     if not isinstance(runner_rc, int):\n1389:         runner_rc = None\n1390: \n1391:     runner_document_rc = execution.get(\n1392:         \"runner_document_rc\"\n1393:     )\n1394:     if not isinstance(runner_document_rc, int):\n1395:         runner_document_rc = None\n1396: \n1397:     wrapper_matches = execution.get(","context_end":1397,"context_start":1377,"line":1387,"matched":["runner_rc"]},{"context":"1378: \n1379:     evidence_sha256 = evidence.get(\"sha256\")\n1380:     if (\n1381:         not isinstance(evidence_sha256, str)\n1382:         or SHA256_RE.fullmatch(evidence_sha256)\n1383:         is None\n1384:     ):\n1385:         evidence_sha256 = None\n1386: \n1387:     runner_rc = execution.get(\"runner_rc\")\n1388:     if not isinstance(runner_rc, int):\n1389:         runner_rc = None\n1390: \n1391:     runner_document_rc = execution.get(\n1392:         \"runner_document_rc\"\n1393:     )\n1394:     if not isinstance(runner_document_rc, int):\n1395:         runner_document_rc = None\n1396: \n1397:     wrapper_matches = execution.get(\n1398:         \"runner_wrapper_matches_document\"","context_end":1398,"context_start":1378,"line":1388,"matched":["runner_rc"]},{"context":"1379:     evidence_sha256 = evidence.get(\"sha256\")\n1380:     if (\n1381:         not isinstance(evidence_sha256, str)\n1382:         or SHA256_RE.fullmatch(evidence_sha256)\n1383:         is None\n1384:     ):\n1385:         evidence_sha256 = None\n1386: \n1387:     runner_rc = execution.get(\"runner_rc\")\n1388:     if not isinstance(runner_rc, int):\n1389:         runner_rc = None\n1390: \n1391:     runner_document_rc = execution.get(\n1392:         \"runner_document_rc\"\n1393:     )\n1394:     if not isinstance(runner_document_rc, int):\n1395:         runner_document_rc = None\n1396: \n1397:     wrapper_matches = execution.get(\n1398:         \"runner_wrapper_matches_document\"\n1399:     )","context_end":1399,"context_start":1379,"line":1389,"matched":["runner_rc"]},{"context":"1381:         not isinstance(evidence_sha256, str)\n1382:         or SHA256_RE.fullmatch(evidence_sha256)\n1383:         is None\n1384:     ):\n1385:         evidence_sha256 = None\n1386: \n1387:     runner_rc = execution.get(\"runner_rc\")\n1388:     if not isinstance(runner_rc, int):\n1389:         runner_rc = None\n1390: \n1391:     runner_document_rc = execution.get(\n1392:         \"runner_document_rc\"\n1393:     )\n1394:     if not isinstance(runner_document_rc, int):\n1395:         runner_document_rc = None\n1396: \n1397:     wrapper_matches = execution.get(\n1398:         \"runner_wrapper_matches_document\"\n1399:     )\n1400:     if not isinstance(wrapper_matches, bool):\n1401:         wrapper_matches = None","context_end":1401,"context_start":1381,"line":1391,"matched":["runner_document_rc"]},{"context":"1382:         or SHA256_RE.fullmatch(evidence_sha256)\n1383:         is None\n1384:     ):\n1385:         evidence_sha256 = None\n1386: \n1387:     runner_rc = execution.get(\"runner_rc\")\n1388:     if not isinstance(runner_rc, int):\n1389:         runner_rc = None\n1390: \n1391:     runner_document_rc = execution.get(\n1392:         \"runner_document_rc\"\n1393:     )\n1394:     if not isinstance(runner_document_rc, int):\n1395:         runner_document_rc = None\n1396: \n1397:     wrapper_matches = execution.get(\n1398:         \"runner_wrapper_matches_document\"\n1399:     )\n1400:     if not isinstance(wrapper_matches, bool):\n1401:         wrapper_matches = None\n1402: ","context_end":1402,"context_start":1382,"line":1392,"matched":["runner_document_rc"]},{"context":"1384:     ):\n1385:         evidence_sha256 = None\n1386: \n1387:     runner_rc = execution.get(\"runner_rc\")\n1388:     if not isinstance(runner_rc, int):\n1389:         runner_rc = None\n1390: \n1391:     runner_document_rc = execution.get(\n1392:         \"runner_document_rc\"\n1393:     )\n1394:     if not isinstance(runner_document_rc, int):\n1395:         runner_document_rc = None\n1396: \n1397:     wrapper_matches = execution.get(\n1398:         \"runner_wrapper_matches_document\"\n1399:     )\n1400:     if not isinstance(wrapper_matches, bool):\n1401:         wrapper_matches = None\n1402: \n1403:     changes_made = state.get(\"changes_made\")\n1404:     if not isinstance(changes_made, bool):","context_end":1404,"context_start":1384,"line":1394,"matched":["runner_document_rc"]},{"context":"1385:         evidence_sha256 = None\n1386: \n1387:     runner_rc = execution.get(\"runner_rc\")\n1388:     if not isinstance(runner_rc, int):\n1389:         runner_rc = None\n1390: \n1391:     runner_document_rc = execution.get(\n1392:         \"runner_document_rc\"\n1393:     )\n1394:     if not isinstance(runner_document_rc, int):\n1395:         runner_document_rc = None\n1396: \n1397:     wrapper_matches = execution.get(\n1398:         \"runner_wrapper_matches_document\"\n1399:     )\n1400:     if not isinstance(wrapper_matches, bool):\n1401:         wrapper_matches = None\n1402: \n1403:     changes_made = state.get(\"changes_made\")\n1404:     if not isinstance(changes_made, bool):\n1405:         changes_made = None","context_end":1405,"context_start":1385,"line":1395,"matched":["runner_document_rc"]},{"context":"1388:     if not isinstance(runner_rc, int):\n1389:         runner_rc = None\n1390: \n1391:     runner_document_rc = execution.get(\n1392:         \"runner_document_rc\"\n1393:     )\n1394:     if not isinstance(runner_document_rc, int):\n1395:         runner_document_rc = None\n1396: \n1397:     wrapper_matches = execution.get(\n1398:         \"runner_wrapper_matches_document\"\n1399:     )\n1400:     if not isinstance(wrapper_matches, bool):\n1401:         wrapper_matches = None\n1402: \n1403:     changes_made = state.get(\"changes_made\")\n1404:     if not isinstance(changes_made, bool):\n1405:         changes_made = None\n1406: \n1407:     rollback_started = state.get(\n1408:         \"rollback_started\"","context_end":1408,"context_start":1388,"line":1398,"matched":["runner_wrapper_matches_document"]},{"context":"1429:             else None\n1430:         ),\n1431:         \"finished_at_utc\": (\n1432:             execution.get(\"finished_at_utc\")\n1433:             if isinstance(\n1434:                 execution.get(\"finished_at_utc\"),\n1435:                 str,\n1436:             )\n1437:             else None\n1438:         ),\n1439:         \"runner_rc\": runner_rc,\n1440:         \"runner_document_rc\": runner_document_rc,\n1441:         \"runner_wrapper_matches_document\": (\n1442:             wrapper_matches\n1443:         ),\n1444:         \"changes_made\": changes_made,\n1445:         \"rollback_started\": rollback_started,\n1446:         \"mutation_outcome\": (\n1447:             public_result_safe_identifier(\n1448:                 state.get(\"mutation_outcome\")\n1449:             )","context_end":1449,"context_start":1429,"line":1439,"matched":["runner_rc"]},{"context":"1430:         ),\n1431:         \"finished_at_utc\": (\n1432:             execution.get(\"finished_at_utc\")\n1433:             if isinstance(\n1434:                 execution.get(\"finished_at_utc\"),\n1435:                 str,\n1436:             )\n1437:             else None\n1438:         ),\n1439:         \"runner_rc\": runner_rc,\n1440:         \"runner_document_rc\": runner_document_rc,\n1441:         \"runner_wrapper_matches_document\": (\n1442:             wrapper_matches\n1443:         ),\n1444:         \"changes_made\": changes_made,\n1445:         \"rollback_started\": rollback_started,\n1446:         \"mutation_outcome\": (\n1447:             public_result_safe_identifier(\n1448:                 state.get(\"mutation_outcome\")\n1449:             )\n1450:         ),","context_end":1450,"context_start":1430,"line":1440,"matched":["runner_document_rc"]},{"context":"1431:         \"finished_at_utc\": (\n1432:             execution.get(\"finished_at_utc\")\n1433:             if isinstance(\n1434:                 execution.get(\"finished_at_utc\"),\n1435:                 str,\n1436:             )\n1437:             else None\n1438:         ),\n1439:         \"runner_rc\": runner_rc,\n1440:         \"runner_document_rc\": runner_document_rc,\n1441:         \"runner_wrapper_matches_document\": (\n1442:             wrapper_matches\n1443:         ),\n1444:         \"changes_made\": changes_made,\n1445:         \"rollback_started\": rollback_started,\n1446:         \"mutation_outcome\": (\n1447:             public_result_safe_identifier(\n1448:                 state.get(\"mutation_outcome\")\n1449:             )\n1450:         ),\n1451:         \"evidence_sha256\": evidence_sha256,","context_end":1451,"context_start":1431,"line":1441,"matched":["runner_wrapper_matches_document"]},{"context":"1546: \n1547: def sanitize_state(state: dict[str, Any]) -> dict[str, Any]:\n1548:     execution = state.get(\"execution\")\n1549:     public_execution = None\n1550:     if isinstance(execution, dict):\n1551:         public_execution = {\n1552:             key: execution.get(key)\n1553:             for key in (\n1554:                 \"started_at_utc\",\n1555:                 \"finished_at_utc\",\n1556:                 \"runner_rc\",\n1557:                 \"runner_document_rc\",\n1558:                 \"runner_status\",\n1559:                 \"runner_wrapper_matches_document\",\n1560:                 \"runner_json_sha256\",\n1561:                 \"runner_text_sha256\",\n1562:             )\n1563:             if key in execution\n1564:         }\n1565: \n1566:     evidence = state.get(\"evidence\")","context_end":1566,"context_start":1546,"line":1556,"matched":["runner_rc"]},{"context":"1547: def sanitize_state(state: dict[str, Any]) -> dict[str, Any]:\n1548:     execution = state.get(\"execution\")\n1549:     public_execution = None\n1550:     if isinstance(execution, dict):\n1551:         public_execution = {\n1552:             key: execution.get(key)\n1553:             for key in (\n1554:                 \"started_at_utc\",\n1555:                 \"finished_at_utc\",\n1556:                 \"runner_rc\",\n1557:                 \"runner_document_rc\",\n1558:                 \"runner_status\",\n1559:                 \"runner_wrapper_matches_document\",\n1560:                 \"runner_json_sha256\",\n1561:                 \"runner_text_sha256\",\n1562:             )\n1563:             if key in execution\n1564:         }\n1565: \n1566:     evidence = state.get(\"evidence\")\n1567:     public_evidence = None","context_end":1567,"context_start":1547,"line":1557,"matched":["runner_document_rc"]},{"context":"1549:     public_execution = None\n1550:     if isinstance(execution, dict):\n1551:         public_execution = {\n1552:             key: execution.get(key)\n1553:             for key in (\n1554:                 \"started_at_utc\",\n1555:                 \"finished_at_utc\",\n1556:                 \"runner_rc\",\n1557:                 \"runner_document_rc\",\n1558:                 \"runner_status\",\n1559:                 \"runner_wrapper_matches_document\",\n1560:                 \"runner_json_sha256\",\n1561:                 \"runner_text_sha256\",\n1562:             )\n1563:             if key in execution\n1564:         }\n1565: \n1566:     evidence = state.get(\"evidence\")\n1567:     public_evidence = None\n1568:     if isinstance(evidence, dict):\n1569:         public_evidence = {","context_end":1569,"context_start":1549,"line":1559,"matched":["runner_wrapper_matches_document"]},{"context":"1685:             if not target.is_file() or target.is_symlink():\n1686:                 raise AdapterError(\n1687:                     f\"payload argv target missing: {relative}\"\n1688:                 )\n1689:             result.append(str(target))\n1690:         else:\n1691:             result.append(value)\n1692:     return result\n1693: \n1694: \n1695: def select_runner_artifacts(\n1696:     command_id: str,\n1697:     started_epoch: float,\n1698: ) -> tuple[Path, Path]:\n1699:     public = Path(\"/var/lib/homelab-chat-run/public\")\n1700:     json_candidates = [\n1701:         path\n1702:         for path in public.glob(f\"{command_id}-*.json\")\n1703:         if path.stat().st_mtime >= started_epoch - 2\n1704:     ]\n1705:     txt_candidates = [","context_end":1705,"context_start":1685,"line":1695,"matched":["select_runner_artifacts"]},{"context":"2039:         except ProcessLookupError:\n2040:             return True\n2041:         time.sleep(0.1)\n2042:     try:\n2043:         os.killpg(pgid, signal.SIGKILL)\n2044:     except ProcessLookupError:\n2045:         pass\n2046:     return True\n2047: \n2048: \n2049: def run_existing_runner(\n2050:     args: list[str],\n2051:     *,\n2052:     timeout: int,\n2053:     environment: dict[str, str],\n2054:     timeout_log: Path,\n2055: ) -> subprocess.CompletedProcess[str]:\n2056:     process = subprocess.Popen(\n2057:         args,\n2058:         stdin=subprocess.DEVNULL,\n2059:         stdout=subprocess.PIPE,","context_end":2059,"context_start":2039,"line":2049,"matched":["run_existing_runner"]},{"context":"2252: \n2253:         started_epoch = time.time()\n2254:         runner_args = [\n2255:             str(RUNNER),\n2256:             state[\"manifest\"][\"command_id\"],\n2257:             state[\"manifest\"][\"mode\"],\n2258:             state[\"manifest\"][\"component\"],\n2259:             \"--\",\n2260:             *argv,\n2261:         ]\n2262:         result = run_existing_runner(\n2263:             runner_args,\n2264:             timeout=(\n2265:                 state[\"manifest\"][\"timeout_seconds\"] + 180\n2266:             ),\n2267:             environment=environment,\n2268:             timeout_log=wrapper_log,\n2269:         )\n2270:         wrapper_log.write_text(\n2271:             result.stdout,\n2272:             encoding=\"utf-8\",","context_end":2272,"context_start":2252,"line":2262,"matched":["run_existing_runner"]},{"context":"2267:             environment=environment,\n2268:             timeout_log=wrapper_log,\n2269:         )\n2270:         wrapper_log.write_text(\n2271:             result.stdout,\n2272:             encoding=\"utf-8\",\n2273:             errors=\"replace\",\n2274:         )\n2275:         os.chmod(wrapper_log, 0o640)\n2276: \n2277:         runner_json, runner_txt = select_runner_artifacts(\n2278:             state[\"manifest\"][\"command_id\"],\n2279:             started_epoch,\n2280:         )\n2281:         runner_document = load_json(runner_json)\n2282: \n2283:         bundle, evidence_sha, evidence_bytes = (\n2284:             create_evidence_bundle(\n2285:                 state=state,\n2286:                 runner_json=runner_json,\n2287:                 runner_txt=runner_txt,","context_end":2287,"context_start":2267,"line":2277,"matched":["select_runner_artifacts"]},{"context":"2321:                 document_rc = int(runner_document[\"rc\"])\n2322:             except (KeyError, TypeError, ValueError) as exc:\n2323:                 raise AdapterError(\"runner artifact rc invalid\") from exc\n2324:             wrapper_matches = result.returncode == document_rc\n2325:             current[\"status\"] = (\n2326:                 document_status if wrapper_matches else \"FAIL\"\n2327:             )\n2328:             current[\"execution\"].update(\n2329:                 {\n2330:                     \"finished_at_utc\": iso(),\n2331:                     \"runner_rc\": result.returncode,\n2332:                     \"runner_document_rc\": document_rc,\n2333:                     \"runner_status\": document_status,\n2334:                     \"runner_wrapper_matches_document\": wrapper_matches,\n2335:                     \"runner_json\": str(runner_json),\n2336:                     \"runner_text\": str(runner_txt),\n2337:                     \"runner_json_sha256\": sha256_file(\n2338:                         runner_json\n2339:                     ),\n2340:                     \"runner_text_sha256\": sha256_file(\n2341:                         runner_txt","context_end":2341,"context_start":2321,"line":2331,"matched":["runner_rc"]},{"context":"2322:             except (KeyError, TypeError, ValueError) as exc:\n2323:                 raise AdapterError(\"runner artifact rc invalid\") from exc\n2324:             wrapper_matches = result.returncode == document_rc\n2325:             current[\"status\"] = (\n2326:                 document_status if wrapper_matches else \"FAIL\"\n2327:             )\n2328:             current[\"execution\"].update(\n2329:                 {\n2330:                     \"finished_at_utc\": iso(),\n2331:                     \"runner_rc\": result.returncode,\n2332:                     \"runner_document_rc\": document_rc,\n2333:                     \"runner_status\": document_status,\n2334:                     \"runner_wrapper_matches_document\": wrapper_matches,\n2335:                     \"runner_json\": str(runner_json),\n2336:                     \"runner_text\": str(runner_txt),\n2337:                     \"runner_json_sha256\": sha256_file(\n2338:                         runner_json\n2339:                     ),\n2340:                     \"runner_text_sha256\": sha256_file(\n2341:                         runner_txt\n2342:                     ),","context_end":2342,"context_start":2322,"line":2332,"matched":["runner_document_rc"]},{"context":"2324:             wrapper_matches = result.returncode == document_rc\n2325:             current[\"status\"] = (\n2326:                 document_status if wrapper_matches else \"FAIL\"\n2327:             )\n2328:             current[\"execution\"].update(\n2329:                 {\n2330:                     \"finished_at_utc\": iso(),\n2331:                     \"runner_rc\": result.returncode,\n2332:                     \"runner_document_rc\": document_rc,\n2333:                     \"runner_status\": document_status,\n2334:                     \"runner_wrapper_matches_document\": wrapper_matches,\n2335:                     \"runner_json\": str(runner_json),\n2336:                     \"runner_text\": str(runner_txt),\n2337:                     \"runner_json_sha256\": sha256_file(\n2338:                         runner_json\n2339:                     ),\n2340:                     \"runner_text_sha256\": sha256_file(\n2341:                         runner_txt\n2342:                     ),\n2343:                 }\n2344:             )","context_end":2344,"context_start":2324,"line":2334,"matched":["runner_wrapper_matches_document"]},{"context":"2346:                 \"object_key\": object_key,\n2347:                 \"sha256\": evidence_sha,\n2348:                 \"bytes\": evidence_bytes,\n2349:                 \"local_bundle\": str(bundle),\n2350:                 \"gateway_verified\": True,\n2351:             }\n2352:             current[\"error\"] = (\n2353:                 None\n2354:                 if wrapper_matches\n2355:                 else {\n2356:                     \"type\": \"RunnerWrapperMismatch\",\n2357:                     \"message\": (\n2358:                         \"existing runner returned a different rc \"\n2359:                         \"after writing its public artifact; \"\n2360:                         \"runtime publication or wrapper completion failed\"\n2361:                     ),\n2362:                 }\n2363:             )\n2364:             atomic_json(path, current)\n2365:         return 0\n2366: ","context_end":2366,"context_start":2346,"line":2356,"matched":["RunnerWrapperMismatch"]},{"context":"2348:                 \"bytes\": evidence_bytes,\n2349:                 \"local_bundle\": str(bundle),\n2350:                 \"gateway_verified\": True,\n2351:             }\n2352:             current[\"error\"] = (\n2353:                 None\n2354:                 if wrapper_matches\n2355:                 else {\n2356:                     \"type\": \"RunnerWrapperMismatch\",\n2357:                     \"message\": (\n2358:                         \"existing runner returned a different rc \"\n2359:                         \"after writing its public artifact; \"\n2360:                         \"runtime publication or wrapper completion failed\"\n2361:                     ),\n2362:                 }\n2363:             )\n2364:             atomic_json(path, current)\n2365:         return 0\n2366: \n2367:     except Exception as exc:\n2368:         try:","context_end":2368,"context_start":2348,"line":2358,"matched":["existing runner returned a different rc"]}],"matches_truncated":false,"path":"/usr/local/sbin/homelab-command-adapter","sha256":"a1a7a615c99568bf915d084cc476f0ebf54ab0eedf3ecd578c4b0e072f58c43d","size":86019,"tail":"2853:             \"backup\": False,\n2854:             \"cluster\": False,\n2855:             \"gitea\": False,\n2856:         },\n2857:         \"rollback\": {\n2858:             \"available\": False,\n2859:             \"description\": \"No changes are performed.\",\n2860:         },\n2861:         \"argv\": [\n2862:             \"/usr/bin/python3\",\n2863:             \"{PAYLOAD}/main.py\",\n2864:         ],\n2865:         \"payload\": [\n2866:             {\n2867:                 \"path\": \"main.py\",\n2868:                 \"mode\": \"0700\",\n2869:                 \"sha256\": sha256_bytes(payload_content),\n2870:                 \"content_b64\": base64.b64encode(\n2871:                     payload_content\n2872:                 ).decode(),\n2873:             }\n2874:         ],\n2875:         \"created_at_utc\": iso(now),\n2876:         \"expires_at_utc\": iso(\n2877:             now + dt.timedelta(hours=1)\n2878:         ),\n2879:     }\n2880:     raw = json.dumps(\n2881:         document,\n2882:         separators=(\",\", \":\"),\n2883:         sort_keys=True,\n2884:     ).encode()\n2885:     with tempfile.TemporaryDirectory() as directory:\n2886:         _, display = validate_capsule(\n2887:             raw,\n2888:             extract_to=Path(directory) / \"payload\",\n2889:         )\n2890:         assert display[\"command_id\"] == \"RUN3-SELF-TEST\"\n2891:         assert (\n2892:             Path(directory) / \"payload\" / \"main.py\"\n2893:         ).read_bytes() == payload_content\n2894: \n2895:     assert len(short_id_for_digest(\"a\" * 64)) >= 10\n2896:     secret_document = dict(document)\n2897:     secret_document[\"argv\"] = [\n2898:         \"/usr/bin/true\",\n2899:         \"--token\",\n2900:         \"not-allowed\",\n2901:     ]\n2902:     secret_raw = json.dumps(\n2903:         secret_document,\n2904:         separators=(\",\", \":\"),\n2905:         sort_keys=True,\n2906:     ).encode()\n2907:     try:\n2908:         validate_capsule(secret_raw)\n2909:     except AdapterError as exc:\n2910:         assert \"secret\" in str(exc).lower()\n2911:     else:\n2912:         raise AssertionError(\"secret-bearing argv accepted\")\n2913:     print(\"SELF_TEST=PASS\")\n2914: \n2915: \n2916: def main() -> int:\n2917:     parser = argparse.ArgumentParser()\n2918:     parser.add_argument(\"--serve\", action=\"store_true\")\n2919:     parser.add_argument(\"--self-test\", action=\"store_true\")\n2920:     parser.add_argument(\"--worker\")\n2921:     parser.add_argument(\"--create-enrollment\")\n2922:     parser.add_argument(\"--enrollment-ttl\", type=int, default=86400)\n2923:     parser.add_argument(\"--cleanup-smoke\")\n2924:     parser.add_argument(\"--cleanup-all-smoke\", action=\"store_true\")\n2925:     args = parser.parse_args()\n2926: \n2927:     if args.self_test:\n2928:         self_test()\n2929:         return 0\n2930:     if args.worker:\n2931:         return worker(args.worker)\n2932:     if args.create_enrollment:\n2933:         ensure_layout()\n2934:         print(\n2935:             json.dumps(\n2936:                 create_enrollment(\n2937:                     args.create_enrollment,\n2938:                     args.enrollment_ttl,\n2939:                 ),\n2940:                 separators=(\",\", \":\"),\n2941:                 sort_keys=True,\n2942:             )\n2943:         )\n2944:         return 0\n2945:     if args.cleanup_smoke:\n2946:         ensure_layout()\n2947:         print(\n2948:             json.dumps(\n2949:                 cleanup_smoke(args.cleanup_smoke),\n2950:                 separators=(\",\", \":\"),\n2951:                 sort_keys=True,\n2952:             )\n2953:         )\n2954:         return 0\n2955:     if args.cleanup_all_smoke:\n2956:         print(\n2957:             json.dumps(\n2958:                 cleanup_all_smoke(),\n2959:                 separators=(\",\", \":\"),\n2960:                 sort_keys=True,\n2961:             )\n2962:         )\n2963:         return 0\n2964:     if args.serve:\n2965:         serve()\n2966:         return 0\n2967:     parser.error(\"one operation is required\")\n2968:     return 64\n2969: \n2970: \n2971: if __name__ == \"__main__\":\n2972:     raise SystemExit(main())"},"adapter_status":{"argv":["systemctl","status","homelab-command-adapter.service","--no-pager","--full"],"name":"adapter_status","rc":0,"stderr":"","stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stderr_truncated":false,"stdout":"● homelab-command-adapter.service - Homelab command adapter\n     Loaded: loaded (/etc/systemd/system/homelab-command-adapter.service; enabled; preset: enabled)\n     Active: active (running) since Tue 2026-07-28 19:50:35 MSK; 1 day 21h ago\n Invocation: 6a223ed5a7524a7098c3b0c348aeae7d\n   Main PID: 1131444 (python3)\n      Tasks: 6 (limit: 34651)\n     Memory: 834.1M (peak: 1.4G)\n        CPU: 1min 31.555s\n     CGroup: /system.slice/homelab-command-adapter.service\n             ├─1131444 /usr/bin/python3 -B /usr/local/sbin/homelab-command-adapter --serve\n             ├─1402402 /usr/bin/python3 -B /usr/local/sbin/homelab-command-adapter --worker DKYKYDZW27\n             ├─1402407 bash /usr/local/sbin/homelab-chat-run RESULT-ACCESS-WRAPPER-RC-PROBE-VERIFY-20260730T135853Z verify result-access -- /usr/bin/python3 -B /var/lib/homelab-command-adapter/capsules/1ab0ac0f36d7c70881adc575ca0d44c374b927588b3b54f30683aeff0b1e1fc9/payload/wrapper_rc_probe_verify.py\n             ├─1402430 timeout --foreground --preserve-status 180 /usr/bin/python3 -B /var/lib/homelab-command-adapter/capsules/1ab0ac0f36d7c70881adc575ca0d44c374b927588b3b54f30683aeff0b1e1fc9/payload/wrapper_rc_probe_verify.py\n             ├─1402431 /usr/bin/python3 -B /var/lib/homelab-command-adapter/capsules/1ab0ac0f36d7c70881adc575ca0d44c374b927588b3b54f30683aeff0b1e1fc9/payload/wrapper_rc_probe_verify.py\n             └─1402434 systemctl status homelab-command-adapter.service --no-pager --full\n\nJul 28 19:50:35 pve01 systemd[1]: Started homelab-command-adapter.service - Homelab command adapter.\n","stdout_sha256":"cc3454dd3e1d69343c6f1b8ed1f082d1312cf02c48f1e84490efdd92308d64ef","stdout_truncated":false},"exact_runner_log":{"content":"FORBIDDEN_PUBLIC_CONTENT\n","content_truncated":false,"exists":true,"gid":990,"mode":"0o640","path":"/var/lib/homelab-command-adapter/runs/L45EGIF44G.runner.log","sha256":"4b56d4a7e68c85bfc60ae2fba309e6c7899bdba695445ab0c7bedaa6c99418a7","size":25,"uid":0},"exact_state":{"content":"{\n  \"bootstrap\": {\n    \"expires_unix\": 1785419891,\n    \"token_sha256\": \"961d3a713ff695c35d0610839a48dd1da856bafa155bd248089f10fa5a1b29cf\",\n    \"used\": true,\n    \"used_unix\": 1785419592\n  },\n  \"capsule_bytes\": 28446,\n  \"capsule_path\": \"/var/lib/homelab-command-adapter/capsules/5f3a4320bce18ab93a8179f2a1a8ce653d3a1b9e84386b2900414a5697a07b85/capsule.hcmd\",\n  \"capsule_sha256\": \"5f3a4320bce18ab93a8179f2a1a8ce653d3a1b9e84386b2900414a5697a07b85\",\n  \"command_object\": {\n    \"bucket\": \"homelab-command-capsules\",\n    \"object_key\": \"capsules/5f3a4320bce18ab93a8179f2a1a8ce653d3a1b9e84386b2900414a5697a07b85.hcmd\",\n    \"verified\": true\n  },\n  \"device\": {\n    \"id\": \"5ba3cc3f52eb70a6\",\n    \"label\": \"win-newpc-20260726\"\n  },\n  \"error\": {\n    \"message\": \"existing runner returned a different rc after writing its public artifact; runtime publication or wrapper completion failed\",\n    \"type\": \"RunnerWrapperMismatch\"\n  },\n  \"evidence\": {\n    \"bytes\": 218473,\n    \"gateway_verified\": true,\n    \"local_bundle\": \"/var/lib/homelab-command-adapter/runs/L45EGIF44G-evidence.tgz\",\n    \"object_key\": \"portal/RESULT-ACCESS-IMPLEMENTATION-PROBE-VERIFY-20260730T135111Z/5f3a4320bce18ab93a8179f2a1a8ce653d3a1b9e84386b2900414a5697a07b85/evidence.tgz\",\n    \"sha256\": \"ec1fc7f2cd34aa1a723d836726083d5439d3c6d94709d8d0706e6dc63237703f\"\n  },\n  \"execution\": {\n    \"finished_at_utc\": \"2026-07-30T13:53:28.276407+00:00\",\n    \"runner_document_rc\": 0,\n    \"runner_json\": \"/var/lib/homelab-chat-run/public/RESULT-ACCESS-IMPLEMENTATION-PROBE-VERIFY-20260730T135111Z-20260730T135320Z.json\",\n    \"runner_json_sha256\": \"e899abc29cc65ff4082011a35d51bb6be48eec994609021cee8def9d241a144f\",\n    \"runner_rc\": 1,\n    \"runner_status\": \"OK\",\n    \"runner_text\": \"/var/lib/homelab-chat-run/public/RESULT-ACCESS-IMPLEMENTATION-PROBE-VERIFY-20260730T135111Z-20260730T135320Z-latest.txt\",\n    \"runner_text_sha256\": \"9dd01d81311262b00bf577fc66319e65039be9e805f83a20ea397c897fbd2299\",\n    \"runner_wrapper_matches_document\": false,\n    \"started_at_utc\": \"2026-07-30T13:53:20.040933+00:00\",\n    \"worker_log\": \"/var/lib/homelab-command-adapter/runs/L45EGIF44G.worker.log\",\n    \"worker_pid\": 1365969\n  },\n  \"imported_at_utc\": \"2026-07-30T13:53:11.219941+00:00\",\n  \"imported_from_ip\": \"100.100.123.213\",\n  \"manifest\": {\n    \"argv\": [\n      \"/usr/bin/python3\",\n      \"-B\",\n      \"{PAYLOAD}/implementation_probe_verify.py\"\n    ],\n    \"change_flags\": {\n      \"backup\": false,\n      \"cluster\": false,\n      \"gitea\": false,\n      \"production\": false\n    },\n    \"command_id\": \"RESULT-ACCESS-IMPLEMENTATION-PROBE-VERIFY-20260730T135111Z\",\n    \"component\": \"result-access\",\n    \"created_at_utc\": \"2026-07-30T13:51:11Z\",\n    \"expires_at_utc\": \"2026-08-02T13:51:11Z\",\n    \"kind\": \"homelab-command-capsule\",\n    \"mode\": \"verify\",\n    \"payload\": [\n      {\n        \"bytes\": 20347,\n        \"mode\": \"0700\",\n        \"path\": \"implementation_probe_verify.py\",\n        \"sha256\": \"a0ea44c6888f61da422b9fb28a211d80b64057020123fc88686793749ed41a37\"\n      }\n    ],\n    \"risk\": \"READ_ONLY\",\n    \"rollback\": {\n      \"available\": false,\n      \"description\": \"No rollback is required: the payload performs only read-only inspection.\"\n    },\n    \"schema_version\": 1,\n    \"summary\": \"Read-only implementation probe. Captures the exact source and hashes of homelab-reader-result-publish, homelab-chat-run, homelab-command-adapter and portal; locates MISSING_CONTRACT and HOMELAB_RESULT_CONTRACT parser logic; finds the exact runner/public/raw/state artifacts for the prior architecture probe and failed recovery; inventories official reader paths, hook wiring, reverse-proxy routes, systemd units and journals. No LATEST result is used as source of truth and no mutation is performed.\",\n    \"target\": \"pve01\",\n    \"timeout_seconds\": 900,\n    \"title\": \"Verify Homelab result-access implementation\"\n  },\n  \"payload_root\": \"/var/lib/homelab-command-adapter/capsules/5f3a4320bce18ab93a8179f2a1a8ce653d3a1b9e84386b2900414a5697a07b85/payload\",\n  \"schema_version\": 1,\n  \"sessions\": [\n    {\n      \"client_ip\": \"100.100.123.213\",\n      \"created_unix\": 1785419592,\n      \"expires_unix\": 1785448392,\n      \"revoked\": false,\n      \"token_sha256\": \"ff8f9674321db5c6391877eb681ed5f86347367fdec35811e3d51b878e1e52a3\"\n    }\n  ],\n  \"short_id\": \"L45EGIF44G\",\n  \"status\": \"FAIL\"\n}\n","content_truncated":false,"exists":true,"gid":990,"mode":"0o640","path":"/var/lib/homelab-command-adapter/state/L45EGIF44G.json","sha256":"5a130168ca0efe741e77421a6912701fce40de3ed67f5d5f83024ee676922756","size":4277,"uid":0},"journal":{"argv":["journalctl","--since","2026-07-30 13:53:10","--until","2026-07-30 13:53:40","--no-pager","-o","short-iso-precise"],"name":"journal_window","rc":0,"stderr":"","stderr_sha256":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","stderr_truncated":false,"stdout":"2026-07-30T13:53:14.915746+03:00 pve01 systemd[1]: Starting homelab-cluster-admin-webpanel-sync.service - Push public pve01 health files to cluster-admin webpanel...\n2026-07-30T13:53:14.916439+03:00 pve01 systemd[1]: Starting homelab-private-vpn-hosts-health.service - Homelab private VPN hosts health check...\n2026-07-30T13:53:15.452911+03:00 pve01 homelab-cluster-admin-webpanel-sync[802925]: STATUS=OK TS=2026-07-30T10:53:14Z TYPE=cluster-admin-webpanel-sync BAD=0 VMID=180 IP=[PRIVATE_IP] SCP_RC=0 SSH_RC=0 PUSHED=cluster-admin-vm-mail-cloud-backup,overall,final-readiness,cluster-admin-strict-final-seal\n2026-07-30T13:53:15.453514+03:00 pve01 systemd[1]: homelab-cluster-admin-webpanel-sync.service: Deactivated successfully.\n2026-07-30T13:53:15.453720+03:00 pve01 systemd[1]: Finished homelab-cluster-admin-webpanel-sync.service - Push public pve01 health files to cluster-admin webpanel.\n2026-07-30T13:53:17.668985+03:00 pve01 systemd[1]: homelab-private-vpn-hosts-health.service: Deactivated successfully.\n2026-07-30T13:53:17.669240+03:00 pve01 systemd[1]: Finished homelab-private-vpn-hosts-health.service - Homelab private VPN hosts health check.\n2026-07-30T13:53:22.647383+03:00 pve01 python3[1278]: [PRIVATE_IP] - - [30/Jul/2026 13:53:22] \"GET /overall.txt HTTP/1.1\" 200 -\n2026-07-30T13:53:23.249673+03:00 pve01 python3[1278]: [PRIVATE_IP] - - [30/Jul/2026 13:53:23] \"GET /overall.txt HTTP/1.1\" 200 -\n2026-07-30T13:53:25.777596+03:00 pve01 sshd-session[802980]: Accepted publickey for root from [PRIVATE_IP] port 59370 ssh2: ED25519 SHA256:G06VmLiLbCMjwki9ArEKqVDZfJYW1N3rrHguI9IHWuE\n2026-07-30T13:53:25.778490+03:00 pve01 sshd-session[802980]: pam_unix(sshd:session): session opened for user root(uid=0) by root(uid=0)\n2026-07-30T13:53:25.784012+03:00 pve01 systemd-logind[991]: New session 4929 of user root.\n2026-07-30T13:53:25.784970+03:00 pve01 systemd[1]: Created slice user-0.slice - User Slice of UID 0.\n2026-07-30T13:53:25.785963+03:00 pve01 systemd[1]: Starting user-runtime-dir@0.service - User Runtime Directory /run/user/0...\n2026-07-30T13:53:25.808766+03:00 pve01 systemd[1]: Finished user-runtime-dir@0.service - User Runtime Directory /run/user/0.\n2026-07-30T13:53:25.810308+03:00 pve01 systemd[1]: Starting user@0.service - User Manager for UID 0...\n2026-07-30T13:53:25.814807+03:00 pve01 (systemd)[802985]: pam_unix(systemd-user:session): session opened for user root(uid=0) by root(uid=0)\n2026-07-30T13:53:25.815991+03:00 pve01 systemd-logind[991]: New session 4930 of user root.\n2026-07-30T13:53:25.884115+03:00 pve01 python3[1278]: [PRIVATE_IP] - - [30/Jul/2026 13:53:25] \"GET /backup.txt HTTP/1.1\" 200 -\n2026-07-30T13:53:25.901114+03:00 pve01 systemd[802985]: Queued start job for default target default.target.\n2026-07-30T13:53:25.911777+03:00 pve01 systemd[802985]: Created slice app.slice - User Application Slice.\n2026-07-30T13:53:25.911791+03:00 pve01 systemd[802985]: Reached target paths.target - Paths.\n2026-07-30T13:53:25.911810+03:00 pve01 systemd[802985]: Reached target timers.target - Timers.\n2026-07-30T13:53:25.912476+03:00 pve01 systemd[802985]: Starting dbus.socket - D-Bus User Message Bus Socket...\n2026-07-30T13:53:25.912519+03:00 pve01 systemd[802985]: Listening on dirmngr.socket - GnuPG network certificate management daemon.\n2026-07-30T13:53:25.912539+03:00 pve01 systemd[802985]: Listening on gpg-agent-browser.socket - GnuPG cryptographic agent and passphrase cache (access for web browsers).\n2026-07-30T13:53:25.912559+03:00 pve01 systemd[802985]: Listening on gpg-agent-extra.socket - GnuPG cryptographic agent and passphrase cache (restricted).\n2026-07-30T13:53:25.912984+03:00 pve01 systemd[802985]: Starting gpg-agent-ssh.socket - GnuPG cryptographic agent (ssh-agent emulation)...\n2026-07-30T13:53:25.913387+03:00 pve01 systemd[802985]: Starting gpg-agent.socket - GnuPG cryptographic agent and passphrase cache...\n2026-07-30T13:53:25.913409+03:00 pve01 systemd[802985]: Listening on keyboxd.socket - GnuPG public key management service.\n2026-07-30T13:53:25.913731+03:00 pve01 systemd[802985]: Starting ssh-agent.socket - OpenSSH Agent socket...\n2026-07-30T13:53:25.921234+03:00 pve01 systemd[802985]: Listening on gpg-agent-ssh.socket - GnuPG cryptographic agent (ssh-agent emulation).\n2026-07-30T13:53:25.922763+03:00 pve01 systemd[802985]: Listening on ssh-agent.socket - OpenSSH Agent socket.\n2026-07-30T13:53:25.923358+03:00 pve01 systemd[802985]: Listening on dbus.socket - D-Bus User Message Bus Socket.\n2026-07-30T13:53:25.923392+03:00 pve01 systemd[802985]: Listening on gpg-agent.socket - GnuPG cryptographic agent and passphrase cache.\n2026-07-30T13:53:25.923767+03:00 pve01 systemd[802985]: Reached target sockets.target - Sockets.\n2026-07-30T13:53:25.923783+03:00 pve01 systemd[802985]: Reached target basic.target - Basic System.\n2026-07-30T13:53:25.923795+03:00 pve01 systemd[802985]: Reached target default.target - Main User Target.\n2026-07-30T13:53:25.923806+03:00 pve01 systemd[802985]: Startup finished in 103ms.\n2026-07-30T13:53:25.923833+03:00 pve01 systemd[1]: Started user@0.service - User Manager for UID 0.\n2026-07-30T13:53:25.924551+03:00 pve01 systemd[1]: Started session-4929.scope - Session 4929 of User root.\n2026-07-30T13:53:25.958018+03:00 pve01 sshd-session[803017]: Received disconnect from [PRIVATE_IP] port 59370:11: disconnected by user\n2026-07-30T13:53:25.958118+03:00 pve01 sshd-session[803017]: Disconnected from user root [PRIVATE_IP] port 59370\n2026-07-30T13:53:25.958580+03:00 pve01 sshd-session[802980]: pam_unix(sshd:session): session closed for user root\n2026-07-30T13:53:25.960200+03:00 pve01 systemd[1]: session-4929.scope: Deactivated successfully.\n2026-07-30T13:53:25.960843+03:00 pve01 systemd-logind[991]: Session 4929 logged out. Waiting for processes to exit.\n2026-07-30T13:53:25.961448+03:00 pve01 systemd-logind[991]: Removed session 4929.\n2026-07-30T13:53:30.801347+03:00 pve01 sshd-session[803024]: Connection closed by [PRIVATE_IP] port 44012\n2026-07-30T13:53:34.747244+03:00 pve01 python3[1278]: [PRIVATE_IP] - - [30/Jul/2026 13:53:34] \"GET /backup-restore-dashboard.txt HTTP/1.1\" 200 -\n2026-07-30T13:53:35.812211+03:00 pve01 python3[1278]: [PRIVATE_IP] - - [30/Jul/2026 13:53:35] \"GET /restore-drill-index.txt HTTP/1.1\" 200 -\n2026-07-30T13:53:36.132263+03:00 pve01 systemd[1]: Stopping user@0.service - User Manager for UID 0...\n2026-07-30T13:53:36.132568+03:00 pve01 systemd[802985]: Activating special unit exit.target...\n2026-07-30T13:53:36.132604+03:00 pve01 systemd[802985]: Stopped target default.target - Main User Target.\n2026-07-30T13:53:36.132616+03:00 pve01 systemd[802985]: Stopped target basic.target - Basic System.\n2026-07-30T13:53:36.132625+03:00 pve01 systemd[802985]: Stopped target paths.target - Paths.\n2026-07-30T13:53:36.132633+03:00 pve01 systemd[802985]: Stopped target sockets.target - Sockets.\n2026-07-30T13:53:36.132642+03:00 pve01 systemd[802985]: Stopped target timers.target - Timers.\n2026-07-30T13:53:36.132800+03:00 pve01 systemd[802985]: Closed dbus.socket - D-Bus User Message Bus Socket.\n2026-07-30T13:53:36.132835+03:00 pve01 systemd[802985]: Closed dirmngr.socket - GnuPG network certificate management daemon.\n2026-07-30T13:53:36.132864+03:00 pve01 systemd[802985]: Closed gpg-agent-browser.socket - GnuPG cryptographic agent and passphrase cache (access for web browsers).\n2026-07-30T13:53:36.132890+03:00 pve01 systemd[802985]: Closed gpg-agent-extra.socket - GnuPG cryptographic agent and passphrase cache (restricted).\n2026-07-30T13:53:36.133532+03:00 pve01 systemd[802985]: Stopping gpg-agent-ssh.socket - GnuPG cryptographic agent (ssh-agent emulation)...\n2026-07-30T13:53:36.133738+03:00 pve01 systemd[802985]: Stopping gpg-agent.socket - GnuPG cryptographic agent and passphrase cache...\n2026-07-30T13:53:36.133768+03:00 pve01 systemd[802985]: Closed keyboxd.socket - GnuPG public key management service.\n2026-07-30T13:53:36.133995+03:00 pve01 systemd[802985]: Stopping ssh-agent.socket - OpenSSH Agent socket...\n2026-07-30T13:53:36.156576+03:00 pve01 systemd[802985]: Closed gpg-agent-ssh.socket - GnuPG cryptographic agent (ssh-agent emulation).\n2026-07-30T13:53:36.159248+03:00 pve01 systemd[802985]: Closed gpg-agent.socket - GnuPG cryptographic agent and passphrase cache.\n2026-07-30T13:53:36.159561+03:00 pve01 systemd[802985]: Closed ssh-agent.socket - OpenSSH Agent socket.\n2026-07-30T13:53:36.161256+03:00 pve01 systemd[802985]: Removed slice app.slice - User Application Slice.\n2026-07-30T13:53:36.161278+03:00 pve01 systemd[802985]: Reached target shutdown.target - Shutdown.\n2026-07-30T13:53:36.161338+03:00 pve01 systemd[802985]: Finished systemd-exit.service - Exit the Session.\n2026-07-30T13:53:36.161350+03:00 pve01 systemd[802985]: Reached target exit.target - Exit the Session.\n2026-07-30T13:53:36.174031+03:00 pve01 systemd-logind[991]: Removed session 4930.\n2026-07-30T13:53:36.174446+03:00 pve01 systemd[1]: user@0.service: Deactivated successfully.\n2026-07-30T13:53:36.174623+03:00 pve01 systemd[1]: Stopped user@0.service - User Manager for UID 0.\n2026-07-30T13:53:36.183173+03:00 pve01 systemd[1]: Stopping user-runtime-dir@0.service - User Runtime Directory /run/user/0...\n2026-07-30T13:53:36.206033+03:00 pve01 systemd[1]: run-user-0.mount: Deactivated successfully.\n2026-07-30T13:53:36.206490+03:00 pve01 systemd[1]: user-runtime-dir@0.service: Deactivated successfully.\n2026-07-30T13:53:36.206566+03:00 pve01 systemd[1]: Stopped user-runtime-dir@0.service - User Runtime Directory /run/user/0.\n2026-07-30T13:53:36.207314+03:00 pve01 systemd[1]: Removed slice user-0.slice - User Slice of UID 0.\n2026-07-30T13:53:36.931739+03:00 pve01 python3[1278]: [PRIVATE_IP] - - [30/Jul/2026 13:53:36] \"GET /adguard-rewrite-sync.txt HTTP/1.1\" 200 -\n2026-07-30T13:53:37.714398+03:00 pve01 python3[1278]: [PRIVATE_IP] - - [30/Jul/2026 13:53:37] \"GET / HTTP/1.1\" 200 -\n","stdout_sha256":"6d009735e898ba188a0a742b5150aeddee87da452c92e27fe796f4b71b242a36","stdout_truncated":false},"official_publisher":{"content":"#!/usr/bin/python3\nimport datetime,hashlib,json,os,re,sys,tempfile,time\nfrom pathlib import Path\nif len(sys.argv)!=6: sys.exit(64)\ncid,commit,summary,raw,rc=sys.argv[1:]\nif not re.fullmatch(r\"[A-Za-z0-9][A-Za-z0-9._-]{0,127}\",cid): sys.exit(65)\nif not re.fullmatch(r\"[0-9a-f]{40}\",commit) or not rc.isdigit(): sys.exit(65)\nbase=Path(raw).name\npub=Path(\"/var/lib/homelab-chat-run/public\")/((base[:-4] if base.endswith(\".log\") else base)+\"-latest.txt\")\nmanifest=Path(\"/var/lib/homelab-reader-v3/manifest.json\")\nresults=Path(\"/var/lib/homelab-reader-v3/results\")\nif not pub.is_file() or pub.is_symlink(): sys.exit(66)\nif not manifest.is_file() or manifest.is_symlink(): sys.exit(66)\nif not results.is_dir() or results.is_symlink(): sys.exit(66)\npayload=pub.read_bytes()\nif (\"COMMAND_ID=\"+cid).encode() not in payload.splitlines(): sys.exit(67)\ndigest=hashlib.sha256(payload).hexdigest()\nname=cid+\"-\"+digest+\".txt\"\nresult=results/name\ndef atomic(path,data,mode):\n    fd,tmp=tempfile.mkstemp(prefix=\".\"+path.name+\".\",dir=str(path.parent))\n    try:\n        with os.fdopen(fd,\"wb\") as out:\n            out.write(data);out.flush();os.fsync(out.fileno())\n        os.chmod(tmp,mode);os.replace(tmp,path)\n        dfd=os.open(str(path.parent),os.O_DIRECTORY);os.fsync(dfd);os.close(dfd)\n    finally:\n        if os.path.exists(tmp): os.unlink(tmp)\nif result.exists():\n    if hashlib.sha256(result.read_bytes()).hexdigest()!=digest: sys.exit(68)\nelse:\n    atomic(result,payload,0o644)\ndef last(prefix,text):\n    values=[line[len(prefix):] for line in text.splitlines() if line.startswith(prefix)]\n    return values[-1] if values else \"\"\nstatus=last(\"STATUS=\",Path(summary).read_text(encoding=\"utf-8\",errors=\"replace\"))\nchanges=last(\"CHANGES_MADE=\",payload.decode(\"utf-8\",\"replace\"))\nif not status: sys.exit(69)\nimmutable=\"https://git.gram1.ru/homelab-admin/homelab-public-context/raw/commit/\"+commit+\"/runtime/history/\"+cid+\".txt\"\npublished=datetime.datetime.now(datetime.timezone.utc).strftime(\"%Y-%m-%dT%H:%M:%SZ\")\ndoc=dict(schema_version=1,generation=str(time.time_ns()),authoritative=False,source_of_truth=\"immutable_history_exact_command_id\",command_id=cid,status=status,rc=int(rc),changes_made=changes.lower() in (\"yes\",\"true\",\"1\"),commit_sha=commit,immutable_result_url=immutable,published_at_utc=published,result=dict(name=name,sha256=digest,bytes=len(payload),path=\"results/\"+name))\ndata=(json.dumps(doc,separators=(\",\",\":\"),ensure_ascii=False)+\"\\n\").encode()\natomic(manifest,data,0o644)\nenv=os.popen(\"/usr/bin/systemctl show homelab-reader-v3.service -p Environment --value\").read()\nmatch=re.search(r\"HOMELAB_READER_CAPABILITY=([0-9a-f]{64})\",env)\nif not match: sys.exit(70)\nurl=\"https://git.gram1.ru/.well-known/homelab-reader/\"+match.group(1)\nprint(\"RESULT_FEED_URL=\"+url+\"/feed\")\nprint(\"RESULT_FEED_RESULT_URL=\"+url+\"/results/\"+name)\nprint(\"RESULT_FEED_RESULT_SHA256=\"+digest)\nprint(\"RESULT_FEED_PUBLICATION=PASS\")\n","content_truncated":false,"exists":true,"gid":0,"mode":"0o750","path":"/usr/local/sbin/homelab-reader-result-publish","sha256":"9cb8f7f1e9f300176a87f1abc8a9c51c92aeb9bea3514c7a9d9019ec400d4fd7","size":2914,"uid":0},"probe":{"command_id":"RESULT-ACCESS-WRAPPER-RC-PROBE-VERIFY-20260730T135853Z","euid":0,"read_only":true,"target_capsule_sha256":"5f3a4320bce18ab93a8179f2a1a8ce653d3a1b9e84386b2900414a5697a07b85","target_command_id":"RESULT-ACCESS-IMPLEMENTATION-PROBE-VERIFY-20260730T135111Z","target_short_id":"L45EGIF44G","uid":0},"runner_source":{"exists":true,"line_count":822,"matches":[{"context":"4: \n5: read_mutation_contract() {\n6:     python3 - \"$1\" \"$2\" \"$3\" \"$4\" <<'PY_CONTRACT'\n7: import json\n8: import sys\n9: from pathlib import Path\n10: \n11: raw_path, command_id, mode, command_rc = sys.argv[1:]\n12: command_rc = int(command_rc)\n13: \n14: result = {\n15:     \"valid\": True,\n16:     \"status\": \"NOT_APPLICABLE\",\n17:     \"changes_made\": \"false\",\n18:     \"rollback_started\": \"false\",","context_end":18,"context_start":4,"line":11,"matched":["COMMAND_RC"]},{"context":"5: read_mutation_contract() {\n6:     python3 - \"$1\" \"$2\" \"$3\" \"$4\" <<'PY_CONTRACT'\n7: import json\n8: import sys\n9: from pathlib import Path\n10: \n11: raw_path, command_id, mode, command_rc = sys.argv[1:]\n12: command_rc = int(command_rc)\n13: \n14: result = {\n15:     \"valid\": True,\n16:     \"status\": \"NOT_APPLICABLE\",\n17:     \"changes_made\": \"false\",\n18:     \"rollback_started\": \"false\",\n19:     \"rollback_restored\": \"null\",","context_end":19,"context_start":5,"line":12,"matched":["COMMAND_RC"]},{"context":"27:         \"status\": \"UNKNOWN\",\n28:         \"changes_made\": \"unknown\",\n29:         \"rollback_started\": \"unknown\",\n30:         \"rollback_restored\": \"null\",\n31:         \"mutation_outcome\": \"UNKNOWN\",\n32:         \"error\": \"MISSING_CONTRACT\",\n33:     }\n34:     marker = \"HOMELAB_RESULT_CONTRACT=\"\n35:     lines = Path(raw_path).read_bytes().decode(\n36:         \"utf-8\",\n37:         errors=\"replace\",\n38:     ).splitlines()\n39:     payloads = [\n40:         line[len(marker):]\n41:         for line in lines","context_end":41,"context_start":27,"line":34,"matched":["RESULT_CONTRACT"]},{"context":"74:             if rollback_started is True and changes is not True:\n75:                 raise ValueError(\n76:                     \"rollback_started without changes\"\n77:                 )\n78:             if status == \"BLOCKED\" and (\n79:                 changes\n80:                 or rollback_started\n81:                 or command_rc != 2\n82:             ):\n83:                 raise ValueError(\n84:                     \"BLOCKED contract inconsistent with rc/mutation\"\n85:                 )\n86:             if status == \"OK\" and command_rc != 0:\n87:                 raise ValueError(\"OK contract inconsistent with rc\")\n88:             if status == \"FAIL\" and command_rc == 0:","context_end":88,"context_start":74,"line":81,"matched":["COMMAND_RC"]},{"context":"79:                 changes\n80:                 or rollback_started\n81:                 or command_rc != 2\n82:             ):\n83:                 raise ValueError(\n84:                     \"BLOCKED contract inconsistent with rc/mutation\"\n85:                 )\n86:             if status == \"OK\" and command_rc != 0:\n87:                 raise ValueError(\"OK contract inconsistent with rc\")\n88:             if status == \"FAIL\" and command_rc == 0:\n89:                 raise ValueError(\"FAIL contract inconsistent with rc\")\n90: \n91:             if not changes:\n92:                 outcome = \"NO_MUTATION\"\n93:             elif not rollback_started:","context_end":93,"context_start":79,"line":86,"matched":["COMMAND_RC"]},{"context":"81:                 or command_rc != 2\n82:             ):\n83:                 raise ValueError(\n84:                     \"BLOCKED contract inconsistent with rc/mutation\"\n85:                 )\n86:             if status == \"OK\" and command_rc != 0:\n87:                 raise ValueError(\"OK contract inconsistent with rc\")\n88:             if status == \"FAIL\" and command_rc == 0:\n89:                 raise ValueError(\"FAIL contract inconsistent with rc\")\n90: \n91:             if not changes:\n92:                 outcome = \"NO_MUTATION\"\n93:             elif not rollback_started:\n94:                 outcome = \"MUTATED\"\n95:             elif rollback_restored is True:","context_end":95,"context_start":81,"line":88,"matched":["COMMAND_RC"]},{"context":"132: ]))\n133: PY_CONTRACT\n134: }\n135: \n136: runner_self_test() {\n137:     local tmp\n138:     tmp=\"$(mktemp)\"\n139:     trap 'rm -f \"$tmp\"' RETURN\n140: \n141:     printf '%s\\n' \\\n142:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T1\",\"status\":\"BLOCKED\",\"changes_made\":false,\"rollback_started\":false,\"rollback_restored\":null}' \\\n143:         >\"$tmp\"\n144:     [ \"$(read_mutation_contract \"$tmp\" T1 change 2)\" = \\\n145:       $'true\\tBLOCKED\\tfalse\\tfalse\\tnull\\tNO_MUTATION\\tNONE' ]\n146: ","context_end":146,"context_start":132,"line":139,"matched":["return\\b"]},{"context":"135: \n136: runner_self_test() {\n137:     local tmp\n138:     tmp=\"$(mktemp)\"\n139:     trap 'rm -f \"$tmp\"' RETURN\n140: \n141:     printf '%s\\n' \\\n142:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T1\",\"status\":\"BLOCKED\",\"changes_made\":false,\"rollback_started\":false,\"rollback_restored\":null}' \\\n143:         >\"$tmp\"\n144:     [ \"$(read_mutation_contract \"$tmp\" T1 change 2)\" = \\\n145:       $'true\\tBLOCKED\\tfalse\\tfalse\\tnull\\tNO_MUTATION\\tNONE' ]\n146: \n147:     printf '%s\\n' \\\n148:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T2\",\"status\":\"OK\",\"changes_made\":true,\"rollback_started\":false,\"rollback_restored\":null}' \\\n149:         >\"$tmp\"","context_end":149,"context_start":135,"line":142,"matched":["RESULT_CONTRACT"]},{"context":"141:     printf '%s\\n' \\\n142:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T1\",\"status\":\"BLOCKED\",\"changes_made\":false,\"rollback_started\":false,\"rollback_restored\":null}' \\\n143:         >\"$tmp\"\n144:     [ \"$(read_mutation_contract \"$tmp\" T1 change 2)\" = \\\n145:       $'true\\tBLOCKED\\tfalse\\tfalse\\tnull\\tNO_MUTATION\\tNONE' ]\n146: \n147:     printf '%s\\n' \\\n148:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T2\",\"status\":\"OK\",\"changes_made\":true,\"rollback_started\":false,\"rollback_restored\":null}' \\\n149:         >\"$tmp\"\n150:     [ \"$(read_mutation_contract \"$tmp\" T2 change 0)\" = \\\n151:       $'true\\tOK\\ttrue\\tfalse\\tnull\\tMUTATED\\tNONE' ]\n152: \n153:     printf '%s\\n' \\\n154:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T3\",\"status\":\"FAIL\",\"changes_made\":true,\"rollback_started\":true,\"rollback_restored\":true}' \\\n155:         >\"$tmp\"","context_end":155,"context_start":141,"line":148,"matched":["RESULT_CONTRACT"]},{"context":"147:     printf '%s\\n' \\\n148:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T2\",\"status\":\"OK\",\"changes_made\":true,\"rollback_started\":false,\"rollback_restored\":null}' \\\n149:         >\"$tmp\"\n150:     [ \"$(read_mutation_contract \"$tmp\" T2 change 0)\" = \\\n151:       $'true\\tOK\\ttrue\\tfalse\\tnull\\tMUTATED\\tNONE' ]\n152: \n153:     printf '%s\\n' \\\n154:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T3\",\"status\":\"FAIL\",\"changes_made\":true,\"rollback_started\":true,\"rollback_restored\":true}' \\\n155:         >\"$tmp\"\n156:     [ \"$(read_mutation_contract \"$tmp\" T3 change 1)\" = \\\n157:       $'true\\tFAIL\\ttrue\\ttrue\\ttrue\\tROLLED_BACK\\tNONE' ]\n158: \n159:     : >\"$tmp\"\n160:     [ \"$(read_mutation_contract \"$tmp\" T4 change 1)\" = \\\n161:       $'false\\tUNKNOWN\\tunknown\\tunknown\\tnull\\tUNKNOWN\\tMISSING_CONTRACT' ]","context_end":161,"context_start":147,"line":154,"matched":["RESULT_CONTRACT"]},{"context":"161:       $'false\\tUNKNOWN\\tunknown\\tunknown\\tnull\\tUNKNOWN\\tMISSING_CONTRACT' ]\n162: \n163:     printf '%s\\n' 'anything' >\"$tmp\"\n164:     [ \"$(read_mutation_contract \"$tmp\" T5 verify 0)\" = \\\n165:       $'true\\tNOT_APPLICABLE\\tfalse\\tfalse\\tnull\\tNO_MUTATION\\tNONE' ]\n166: \n167:     printf '%s\\n' \\\n168:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"OTHER\",\"status\":\"OK\",\"changes_made\":true,\"rollback_started\":false,\"rollback_restored\":null}' \\\n169:         >\"$tmp\"\n170:     [ \"$(read_mutation_contract \"$tmp\" T6 change 0)\" = \\\n171:       $'false\\tUNKNOWN\\tunknown\\tunknown\\tnull\\tUNKNOWN\\tINVALID_CONTRACT:ValueError' ]\n172: \n173:     printf '%s\\n' \\\n174:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T7\",\"status\":\"OK\",\"changes_made\":true,\"rollback_started\":false,\"rollback_restored\":null}' \\\n175:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T7\",\"status\":\"OK\",\"changes_made\":true,\"rollback_started\":false,\"rollback_restored\":null}' \\","context_end":175,"context_start":161,"line":168,"matched":["RESULT_CONTRACT"]},{"context":"167:     printf '%s\\n' \\\n168:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"OTHER\",\"status\":\"OK\",\"changes_made\":true,\"rollback_started\":false,\"rollback_restored\":null}' \\\n169:         >\"$tmp\"\n170:     [ \"$(read_mutation_contract \"$tmp\" T6 change 0)\" = \\\n171:       $'false\\tUNKNOWN\\tunknown\\tunknown\\tnull\\tUNKNOWN\\tINVALID_CONTRACT:ValueError' ]\n172: \n173:     printf '%s\\n' \\\n174:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T7\",\"status\":\"OK\",\"changes_made\":true,\"rollback_started\":false,\"rollback_restored\":null}' \\\n175:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T7\",\"status\":\"OK\",\"changes_made\":true,\"rollback_started\":false,\"rollback_restored\":null}' \\\n176:         >\"$tmp\"\n177:     [ \"$(read_mutation_contract \"$tmp\" T7 change 0)\" = \\\n178:       $'false\\tUNKNOWN\\tunknown\\tunknown\\tnull\\tUNKNOWN\\tMULTIPLE_CONTRACTS' ]\n179: \n180:     echo 'SELF_TEST=PASS'\n181: }","context_end":181,"context_start":167,"line":174,"matched":["RESULT_CONTRACT"]},{"context":"168:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"OTHER\",\"status\":\"OK\",\"changes_made\":true,\"rollback_started\":false,\"rollback_restored\":null}' \\\n169:         >\"$tmp\"\n170:     [ \"$(read_mutation_contract \"$tmp\" T6 change 0)\" = \\\n171:       $'false\\tUNKNOWN\\tunknown\\tunknown\\tnull\\tUNKNOWN\\tINVALID_CONTRACT:ValueError' ]\n172: \n173:     printf '%s\\n' \\\n174:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T7\",\"status\":\"OK\",\"changes_made\":true,\"rollback_started\":false,\"rollback_restored\":null}' \\\n175:         'HOMELAB_RESULT_CONTRACT={\"version\":1,\"command_id\":\"T7\",\"status\":\"OK\",\"changes_made\":true,\"rollback_started\":false,\"rollback_restored\":null}' \\\n176:         >\"$tmp\"\n177:     [ \"$(read_mutation_contract \"$tmp\" T7 change 0)\" = \\\n178:       $'false\\tUNKNOWN\\tunknown\\tunknown\\tnull\\tUNKNOWN\\tMULTIPLE_CONTRACTS' ]\n179: \n180:     echo 'SELF_TEST=PASS'\n181: }\n182: ","context_end":182,"context_start":168,"line":175,"matched":["RESULT_CONTRACT"]},{"context":"178:       $'false\\tUNKNOWN\\tunknown\\tunknown\\tnull\\tUNKNOWN\\tMULTIPLE_CONTRACTS' ]\n179: \n180:     echo 'SELF_TEST=PASS'\n181: }\n182: \n183: if [ \"${1:-}\" = '--self-test' ]; then\n184:     runner_self_test\n185:     exit 0\n186: fi\n187: \n188: usage() {\n189:     cat >&2 <<'USAGE'\n190: Usage:\n191:   homelab-chat-run COMMAND_ID MODE COMPONENT -- command [arguments...]\n192: ","context_end":192,"context_start":178,"line":185,"matched":["exit\\b"]},{"context":"196:   change\n197:   transport-test\n198: \n199: Environment:\n200:   HOMELAB_ALLOW_REPEAT=1   Allow exact repeat of a previously failed command.\n201:   HOMELAB_TIMEOUT=SECONDS  Optional command timeout.\n202: USAGE\n203:     exit 64\n204: }\n205: \n206: [ \"$#\" -ge 5 ] || usage\n207: \n208: COMMAND_ID=\"$1\"\n209: MODE=\"$2\"\n210: COMPONENT=\"$3\"","context_end":210,"context_start":196,"line":203,"matched":["exit\\b"]},{"context":"214: shift\n215: [ \"$#\" -ge 1 ] || usage\n216: \n217: case \"$COMMAND_ID\" in\n218:     ''|*[!A-Za-z0-9._-]*)\n219:         echo 'RESULT=FAIL'\n220:         echo 'REASON=INVALID_COMMAND_ID'\n221:         exit 65\n222:         ;;\n223: esac\n224: \n225: case \"$COMPONENT\" in\n226:     ''|*[!A-Za-z0-9._-]*)\n227:         echo 'RESULT=FAIL'\n228:         echo 'REASON=INVALID_COMPONENT'","context_end":228,"context_start":214,"line":221,"matched":["exit\\b"]},{"context":"222:         ;;\n223: esac\n224: \n225: case \"$COMPONENT\" in\n226:     ''|*[!A-Za-z0-9._-]*)\n227:         echo 'RESULT=FAIL'\n228:         echo 'REASON=INVALID_COMPONENT'\n229:         exit 66\n230:         ;;\n231: esac\n232: \n233: case \"$MODE\" in\n234:     read-only|verify|change|transport-test)\n235:         ;;\n236:     *)","context_end":236,"context_start":222,"line":229,"matched":["exit\\b"]},{"context":"232: \n233: case \"$MODE\" in\n234:     read-only|verify|change|transport-test)\n235:         ;;\n236:     *)\n237:         echo 'RESULT=FAIL'\n238:         echo 'REASON=INVALID_MODE'\n239:         exit 67\n240:         ;;\n241: esac\n242: \n243: for TOOL in \\\n244:     awk \\\n245:     curl \\\n246:     flock \\","context_end":246,"context_start":232,"line":239,"matched":["exit\\b"]},{"context":"238:         echo 'REASON=INVALID_MODE'\n239:         exit 67\n240:         ;;\n241: esac\n242: \n243: for TOOL in \\\n244:     awk \\\n245:     curl \\\n246:     flock \\\n247:     python3 \\\n248:     scp \\\n249:     sha256sum \\\n250:     ssh\n251: do\n252:     command -v \"$TOOL\" >/dev/null 2>&1 || {","context_end":252,"context_start":238,"line":245,"matched":["curl\\b"]},{"context":"241: esac\n242: \n243: for TOOL in \\\n244:     awk \\\n245:     curl \\\n246:     flock \\\n247:     python3 \\\n248:     scp \\\n249:     sha256sum \\\n250:     ssh\n251: do\n252:     command -v \"$TOOL\" >/dev/null 2>&1 || {\n253:         echo 'RESULT=FAIL'\n254:         echo \"REASON=REQUIRED_TOOL_MISSING:$TOOL\"\n255:         exit 68","context_end":255,"context_start":241,"line":248,"matched":["scp\\b"]},{"context":"243: for TOOL in \\\n244:     awk \\\n245:     curl \\\n246:     flock \\\n247:     python3 \\\n248:     scp \\\n249:     sha256sum \\\n250:     ssh\n251: do\n252:     command -v \"$TOOL\" >/dev/null 2>&1 || {\n253:         echo 'RESULT=FAIL'\n254:         echo \"REASON=REQUIRED_TOOL_MISSING:$TOOL\"\n255:         exit 68\n256:     }\n257: done","context_end":257,"context_start":243,"line":250,"matched":["ssh\\b"]},{"context":"248:     scp \\\n249:     sha256sum \\\n250:     ssh\n251: do\n252:     command -v \"$TOOL\" >/dev/null 2>&1 || {\n253:         echo 'RESULT=FAIL'\n254:         echo \"REASON=REQUIRED_TOOL_MISSING:$TOOL\"\n255:         exit 68\n256:     }\n257: done\n258: \n259: REFERENCE=/etc/pve/31_HOMELAB_REFERENCE.md\n260: ERROR_REGISTER=/etc/pve/HOMELAB_ASSISTANT_ERROR_REGISTER.md\n261: \n262: [ -r \"$REFERENCE\" ] || {","context_end":262,"context_start":248,"line":255,"matched":["exit\\b"]},{"context":"258: \n259: REFERENCE=/etc/pve/31_HOMELAB_REFERENCE.md\n260: ERROR_REGISTER=/etc/pve/HOMELAB_ASSISTANT_ERROR_REGISTER.md\n261: \n262: [ -r \"$REFERENCE\" ] || {\n263:     echo 'RESULT=FAIL'\n264:     echo 'REASON=REFERENCE_NOT_READABLE'\n265:     exit 69\n266: }\n267: \n268: [ -r \"$ERROR_REGISTER\" ] || {\n269:     echo 'RESULT=FAIL'\n270:     echo 'REASON=ERROR_REGISTER_NOT_READABLE'\n271:     exit 70\n272: }","context_end":272,"context_start":258,"line":265,"matched":["exit\\b"]},{"context":"264:     echo 'REASON=REFERENCE_NOT_READABLE'\n265:     exit 69\n266: }\n267: \n268: [ -r \"$ERROR_REGISTER\" ] || {\n269:     echo 'RESULT=FAIL'\n270:     echo 'REASON=ERROR_REGISTER_NOT_READABLE'\n271:     exit 70\n272: }\n273: \n274: STATE_DIR=/var/lib/homelab-chat-run\n275: RAW_DIR=\"$STATE_DIR/raw\"\n276: PUBLIC_DIR=\"$STATE_DIR/public\"\n277: LEDGER=\"$STATE_DIR/state/command-ledger.tsv\"\n278: LOCK=\"$STATE_DIR/state/runner.lock\"","context_end":278,"context_start":264,"line":271,"matched":["exit\\b"]},{"context":"283: chmod 0600 \"$LEDGER\"\n284: \n285: exec 9>\"$LOCK\"\n286: \n287: flock -w 60 9 || {\n288:     echo 'RESULT=FAIL'\n289:     echo 'REASON=RUNNER_LOCK_TIMEOUT'\n290:     exit 71\n291: }\n292: \n293: STARTED_AT=\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"\n294: STAMP=\"$(date -u +%Y%m%dT%H%M%SZ)\"\n295: HOST_SHORT=\"$(hostname -s 2>/dev/null || hostname)\"\n296: \n297: RAW_FILE=\"$RAW_DIR/${COMMAND_ID}-${STAMP}.log\"","context_end":297,"context_start":283,"line":290,"matched":["exit\\b"]},{"context":"293: STARTED_AT=\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"\n294: STAMP=\"$(date -u +%Y%m%dT%H%M%SZ)\"\n295: HOST_SHORT=\"$(hostname -s 2>/dev/null || hostname)\"\n296: \n297: RAW_FILE=\"$RAW_DIR/${COMMAND_ID}-${STAMP}.log\"\n298: SANITIZED_FILE=\"$PUBLIC_DIR/${COMMAND_ID}-${STAMP}.txt\"\n299: JSON_FILE=\"$PUBLIC_DIR/${COMMAND_ID}-${STAMP}.json\"\n300: TXT_FILE=\"$PUBLIC_DIR/${COMMAND_ID}-${STAMP}-latest.txt\"\n301: \n302: REFERENCE_SHA256=\"$(sha256sum \"$REFERENCE\" | awk '{print $1}')\"\n303: ERROR_REGISTER_SHA256=\"$(sha256sum \"$ERROR_REGISTER\" | awk '{print $1}')\"\n304: \n305: COMMAND_SHA256=\"$(\n306:     {\n307:         printf '%s\\0' \"$MODE\"","context_end":307,"context_start":293,"line":300,"matched":["latest"]},{"context":"324:     ' \"$LEDGER\"\n325: )\"\n326: \n327: RUN_STARTED=true\n328: REPEAT_BLOCKED=false\n329: BLOCK_REASON=''\n330: CHANGE_DECLARED=false\n331: RESULT_CONTRACT_VALID=true\n332: CONTRACT_STATUS='NOT_APPLICABLE'\n333: CHANGES_MADE=false\n334: ROLLBACK_STARTED=false\n335: ROLLBACK_RESTORED=null\n336: MUTATION_OUTCOME='NO_MUTATION'\n337: RESULT_CONTRACT_ERROR='NONE'\n338: COMMAND_RC=''","context_end":338,"context_start":324,"line":331,"matched":["RESULT_CONTRACT"]},{"context":"330: CHANGE_DECLARED=false\n331: RESULT_CONTRACT_VALID=true\n332: CONTRACT_STATUS='NOT_APPLICABLE'\n333: CHANGES_MADE=false\n334: ROLLBACK_STARTED=false\n335: ROLLBACK_RESTORED=null\n336: MUTATION_OUTCOME='NO_MUTATION'\n337: RESULT_CONTRACT_ERROR='NONE'\n338: COMMAND_RC=''\n339: \n340: if [ \"$MODE\" = change ]; then\n341:     CHANGE_DECLARED=true\n342:     RESULT_CONTRACT_VALID=false\n343:     CONTRACT_STATUS='UNKNOWN'\n344:     CHANGES_MADE=unknown","context_end":344,"context_start":330,"line":337,"matched":["RESULT_CONTRACT"]},{"context":"331: RESULT_CONTRACT_VALID=true\n332: CONTRACT_STATUS='NOT_APPLICABLE'\n333: CHANGES_MADE=false\n334: ROLLBACK_STARTED=false\n335: ROLLBACK_RESTORED=null\n336: MUTATION_OUTCOME='NO_MUTATION'\n337: RESULT_CONTRACT_ERROR='NONE'\n338: COMMAND_RC=''\n339: \n340: if [ \"$MODE\" = change ]; then\n341:     CHANGE_DECLARED=true\n342:     RESULT_CONTRACT_VALID=false\n343:     CONTRACT_STATUS='UNKNOWN'\n344:     CHANGES_MADE=unknown\n345:     ROLLBACK_STARTED=unknown","context_end":345,"context_start":331,"line":338,"matched":["COMMAND_RC"]},{"context":"335: ROLLBACK_RESTORED=null\n336: MUTATION_OUTCOME='NO_MUTATION'\n337: RESULT_CONTRACT_ERROR='NONE'\n338: COMMAND_RC=''\n339: \n340: if [ \"$MODE\" = change ]; then\n341:     CHANGE_DECLARED=true\n342:     RESULT_CONTRACT_VALID=false\n343:     CONTRACT_STATUS='UNKNOWN'\n344:     CHANGES_MADE=unknown\n345:     ROLLBACK_STARTED=unknown\n346:     ROLLBACK_RESTORED=null\n347:     MUTATION_OUTCOME='UNKNOWN'\n348:     RESULT_CONTRACT_ERROR='MISSING_CONTRACT'\n349: fi","context_end":349,"context_start":335,"line":342,"matched":["RESULT_CONTRACT"]},{"context":"341:     CHANGE_DECLARED=true\n342:     RESULT_CONTRACT_VALID=false\n343:     CONTRACT_STATUS='UNKNOWN'\n344:     CHANGES_MADE=unknown\n345:     ROLLBACK_STARTED=unknown\n346:     ROLLBACK_RESTORED=null\n347:     MUTATION_OUTCOME='UNKNOWN'\n348:     RESULT_CONTRACT_ERROR='MISSING_CONTRACT'\n349: fi\n350: \n351: if [ -n \"$PREVIOUS_FAILED_RC\" ] &&\n352:    [ \"${HOMELAB_ALLOW_REPEAT:-0}\" != 1 ]; then\n353: \n354:     RUN_STARTED=false\n355:     REPEAT_BLOCKED=true","context_end":355,"context_start":341,"line":348,"matched":["RESULT_CONTRACT"]},{"context":"352:    [ \"${HOMELAB_ALLOW_REPEAT:-0}\" != 1 ]; then\n353: \n354:     RUN_STARTED=false\n355:     REPEAT_BLOCKED=true\n356:     BLOCK_REASON='EXACT_FAILED_COMMAND_REPEAT'\n357:     RC=73\n358:     STATUS='BLOCKED'\n359:     RESULT_CONTRACT_VALID=true\n360:     CONTRACT_STATUS='BLOCKED'\n361:     CHANGES_MADE=false\n362:     ROLLBACK_STARTED=false\n363:     ROLLBACK_RESTORED=null\n364:     MUTATION_OUTCOME='NO_MUTATION'\n365:     RESULT_CONTRACT_ERROR='RUNNER_PREEXECUTION_BLOCK'\n366: ","context_end":366,"context_start":352,"line":359,"matched":["RESULT_CONTRACT"]},{"context":"358:     STATUS='BLOCKED'\n359:     RESULT_CONTRACT_VALID=true\n360:     CONTRACT_STATUS='BLOCKED'\n361:     CHANGES_MADE=false\n362:     ROLLBACK_STARTED=false\n363:     ROLLBACK_RESTORED=null\n364:     MUTATION_OUTCOME='NO_MUTATION'\n365:     RESULT_CONTRACT_ERROR='RUNNER_PREEXECUTION_BLOCK'\n366: \n367:     {\n368:         echo 'COMMAND_EXECUTION_BLOCKED=yes'\n369:         echo 'REASON=EXACT_FAILED_COMMAND_REPEAT'\n370:         echo \"PREVIOUS_RC=$PREVIOUS_FAILED_RC\"\n371:         echo \"COMMAND_SHA256=$COMMAND_SHA256\"\n372:         echo","context_end":372,"context_start":358,"line":365,"matched":["RESULT_CONTRACT"]},{"context":"376:     set +e\n377: \n378:     if [ -n \"${HOMELAB_TIMEOUT:-}\" ]; then\n379:         case \"$HOMELAB_TIMEOUT\" in\n380:             *[!0-9]*|'')\n381:                 echo 'RESULT=FAIL'\n382:                 echo 'REASON=INVALID_HOMELAB_TIMEOUT'\n383:                 exit 74\n384:                 ;;\n385:         esac\n386: \n387:         timeout \\\n388:             --foreground \\\n389:             --preserve-status \\\n390:             \"$HOMELAB_TIMEOUT\" \\","context_end":390,"context_start":376,"line":383,"matched":["exit\\b"]},{"context":"393:     else\n394:         \"$@\" >\"$RAW_FILE\" 2>&1\n395:         RC=$?\n396:     fi\n397: \n398:     set -e\n399: \n400:     COMMAND_RC=\"$RC\"\n401: \n402:     if [ \"$RC\" -eq 0 ]; then\n403:         STATUS='OK'\n404:     else\n405:         STATUS='FAIL'\n406:     fi\n407: ","context_end":407,"context_start":393,"line":400,"matched":["COMMAND_RC"]},{"context":"402:     if [ \"$RC\" -eq 0 ]; then\n403:         STATUS='OK'\n404:     else\n405:         STATUS='FAIL'\n406:     fi\n407: \n408:     IFS=$'\\t' read -r \\\n409:         RESULT_CONTRACT_VALID \\\n410:         CONTRACT_STATUS \\\n411:         CHANGES_MADE \\\n412:         ROLLBACK_STARTED \\\n413:         ROLLBACK_RESTORED \\\n414:         MUTATION_OUTCOME \\\n415:         RESULT_CONTRACT_ERROR < <(\n416:             read_mutation_contract \\","context_end":416,"context_start":402,"line":409,"matched":["RESULT_CONTRACT"]},{"context":"408:     IFS=$'\\t' read -r \\\n409:         RESULT_CONTRACT_VALID \\\n410:         CONTRACT_STATUS \\\n411:         CHANGES_MADE \\\n412:         ROLLBACK_STARTED \\\n413:         ROLLBACK_RESTORED \\\n414:         MUTATION_OUTCOME \\\n415:         RESULT_CONTRACT_ERROR < <(\n416:             read_mutation_contract \\\n417:                 \"$RAW_FILE\" \\\n418:                 \"$COMMAND_ID\" \\\n419:                 \"$MODE\" \\\n420:                 \"$COMMAND_RC\"\n421:         )\n422: ","context_end":422,"context_start":408,"line":415,"matched":["RESULT_CONTRACT"]},{"context":"413:         ROLLBACK_RESTORED \\\n414:         MUTATION_OUTCOME \\\n415:         RESULT_CONTRACT_ERROR < <(\n416:             read_mutation_contract \\\n417:                 \"$RAW_FILE\" \\\n418:                 \"$COMMAND_ID\" \\\n419:                 \"$MODE\" \\\n420:                 \"$COMMAND_RC\"\n421:         )\n422: \n423:     if [ \"$MODE\" = change ]; then\n424:         if [ \"$RESULT_CONTRACT_VALID\" != true ]; then\n425:             RC=76\n426:             STATUS='FAIL'\n427:         else","context_end":427,"context_start":413,"line":420,"matched":["COMMAND_RC"]},{"context":"417:                 \"$RAW_FILE\" \\\n418:                 \"$COMMAND_ID\" \\\n419:                 \"$MODE\" \\\n420:                 \"$COMMAND_RC\"\n421:         )\n422: \n423:     if [ \"$MODE\" = change ]; then\n424:         if [ \"$RESULT_CONTRACT_VALID\" != true ]; then\n425:             RC=76\n426:             STATUS='FAIL'\n427:         else\n428:             STATUS=\"$CONTRACT_STATUS\"\n429:         fi\n430:     fi\n431: fi","context_end":431,"context_start":417,"line":424,"matched":["RESULT_CONTRACT"]},{"context":"442: target = Path(sys.argv[2])\n443: \n444: text = source.read_bytes().decode(\"utf-8\", errors=\"replace\")\n445: \n446: patterns = [\n447:     (\n448:         re.compile(\n449:             r\"-----BEGIN (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----\"\n450:             r\".*?\"\n451:             r\"-----END (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----\",\n452:             re.IGNORECASE | re.DOTALL,\n453:         ),\n454:         \"[PRIVATE_KEY_REDACTED]\",\n455:     ),\n456:     (","context_end":456,"context_start":442,"line":449,"matched":["ssh\\b"]},{"context":"444: text = source.read_bytes().decode(\"utf-8\", errors=\"replace\")\n445: \n446: patterns = [\n447:     (\n448:         re.compile(\n449:             r\"-----BEGIN (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----\"\n450:             r\".*?\"\n451:             r\"-----END (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----\",\n452:             re.IGNORECASE | re.DOTALL,\n453:         ),\n454:         \"[PRIVATE_KEY_REDACTED]\",\n455:     ),\n456:     (\n457:         re.compile(\n458:             r\"(?im)^(\\s*(?:password|passwd|passphrase|authorization|\"","context_end":458,"context_start":444,"line":451,"matched":["ssh\\b"]},{"context":"486:     (\n487:         re.compile(\n488:             r\"(?i)\\bfe[89ab][0-9a-f](?::[0-9a-f]{0,4}){2,7}\\b\"\n489:         ),\n490:         \"[LINK_LOCAL_IPV6]\",\n491:     ),\n492:     (\n493:         re.compile(r\"(?i)/root/\\.ssh(?:/\\S*)?\"),\n494:         \"[SENSITIVE_PATH]\",\n495:     ),\n496:     (\n497:         re.compile(r\"(?i)[SENSITIVE_PATH](?:/\\S*)?\"),\n498:         \"[SENSITIVE_PATH]\",\n499:     ),\n500:     (","context_end":500,"context_start":486,"line":493,"matched":["ssh\\b"]},{"context":"556:     \"$COMMAND_SHA256\" \\\n557:     \"$RAW_SHA256\" \\\n558:     \"$SANITIZED_SHA256\" \\\n559:     \"$RUN_STARTED\" \\\n560:     \"$REPEAT_BLOCKED\" \\\n561:     \"$BLOCK_REASON\" \\\n562:     \"$CHANGE_DECLARED\" \\\n563:     \"$RESULT_CONTRACT_VALID\" \\\n564:     \"$CONTRACT_STATUS\" \\\n565:     \"$CHANGES_MADE\" \\\n566:     \"$ROLLBACK_STARTED\" \\\n567:     \"$ROLLBACK_RESTORED\" \\\n568:     \"$MUTATION_OUTCOME\" \\\n569:     \"$RESULT_CONTRACT_ERROR\" \\\n570:     \"$COMMAND_RC\" <<'PY'","context_end":570,"context_start":556,"line":563,"matched":["RESULT_CONTRACT"]},{"context":"562:     \"$CHANGE_DECLARED\" \\\n563:     \"$RESULT_CONTRACT_VALID\" \\\n564:     \"$CONTRACT_STATUS\" \\\n565:     \"$CHANGES_MADE\" \\\n566:     \"$ROLLBACK_STARTED\" \\\n567:     \"$ROLLBACK_RESTORED\" \\\n568:     \"$MUTATION_OUTCOME\" \\\n569:     \"$RESULT_CONTRACT_ERROR\" \\\n570:     \"$COMMAND_RC\" <<'PY'\n571: import json\n572: import sys\n573: from pathlib import Path\n574: \n575: (\n576:     json_path,","context_end":576,"context_start":562,"line":569,"matched":["RESULT_CONTRACT"]},{"context":"563:     \"$RESULT_CONTRACT_VALID\" \\\n564:     \"$CONTRACT_STATUS\" \\\n565:     \"$CHANGES_MADE\" \\\n566:     \"$ROLLBACK_STARTED\" \\\n567:     \"$ROLLBACK_RESTORED\" \\\n568:     \"$MUTATION_OUTCOME\" \\\n569:     \"$RESULT_CONTRACT_ERROR\" \\\n570:     \"$COMMAND_RC\" <<'PY'\n571: import json\n572: import sys\n573: from pathlib import Path\n574: \n575: (\n576:     json_path,\n577:     output_path,","context_end":577,"context_start":563,"line":570,"matched":["COMMAND_RC"]},{"context":"588:     command_sha,\n589:     raw_sha,\n590:     sanitized_sha,\n591:     run_started,\n592:     repeat_blocked,\n593:     block_reason,\n594:     change_declared,\n595:     result_contract_valid,\n596:     contract_status,\n597:     changes_made,\n598:     rollback_started,\n599:     rollback_restored,\n600:     mutation_outcome,\n601:     result_contract_error,\n602:     command_rc,","context_end":602,"context_start":588,"line":595,"matched":["RESULT_CONTRACT"]},{"context":"594:     change_declared,\n595:     result_contract_valid,\n596:     contract_status,\n597:     changes_made,\n598:     rollback_started,\n599:     rollback_restored,\n600:     mutation_outcome,\n601:     result_contract_error,\n602:     command_rc,\n603: ) = sys.argv[1:]\n604: \n605: \n606: def optional_bool(value: str):\n607:     if value == \"true\":\n608:         return True","context_end":608,"context_start":594,"line":601,"matched":["RESULT_CONTRACT"]},{"context":"595:     result_contract_valid,\n596:     contract_status,\n597:     changes_made,\n598:     rollback_started,\n599:     rollback_restored,\n600:     mutation_outcome,\n601:     result_contract_error,\n602:     command_rc,\n603: ) = sys.argv[1:]\n604: \n605: \n606: def optional_bool(value: str):\n607:     if value == \"true\":\n608:         return True\n609:     if value == \"false\":","context_end":609,"context_start":595,"line":602,"matched":["COMMAND_RC"]},{"context":"601:     result_contract_error,\n602:     command_rc,\n603: ) = sys.argv[1:]\n604: \n605: \n606: def optional_bool(value: str):\n607:     if value == \"true\":\n608:         return True\n609:     if value == \"false\":\n610:         return False\n611:     return None\n612: \n613: output = Path(output_path).read_text(\n614:     encoding=\"utf-8\",\n615:     errors=\"replace\",","context_end":615,"context_start":601,"line":608,"matched":["return\\b"]},{"context":"603: ) = sys.argv[1:]\n604: \n605: \n606: def optional_bool(value: str):\n607:     if value == \"true\":\n608:         return True\n609:     if value == \"false\":\n610:         return False\n611:     return None\n612: \n613: output = Path(output_path).read_text(\n614:     encoding=\"utf-8\",\n615:     errors=\"replace\",\n616: )\n617: ","context_end":617,"context_start":603,"line":610,"matched":["return\\b"]},{"context":"604: \n605: \n606: def optional_bool(value: str):\n607:     if value == \"true\":\n608:         return True\n609:     if value == \"false\":\n610:         return False\n611:     return None\n612: \n613: output = Path(output_path).read_text(\n614:     encoding=\"utf-8\",\n615:     errors=\"replace\",\n616: )\n617: \n618: encoded = output.encode(\"utf-8\")","context_end":618,"context_start":604,"line":611,"matched":["return\\b"]},{"context":"625:         errors=\"ignore\",\n626:     )\n627: else:\n628:     output_preview = output\n629: \n630: document = {\n631:     \"schema_version\": 1,\n632:     \"channel\": \"homelab-runtime\",\n633:     \"command_id\": command_id,\n634:     \"status\": status,\n635:     \"rc\": int(rc),\n636:     \"host\": host,\n637:     \"mode\": mode,\n638:     \"component\": component,\n639:     \"started_at_utc\": started,","context_end":639,"context_start":625,"line":632,"matched":["homelab-runtime"]},{"context":"643:     \"error_register_checked\": True,\n644:     \"error_register_sha256\": error_sha,\n645:     \"command_sha256\": command_sha,\n646:     \"duplicate_failed_command_blocked\": repeat_blocked == \"true\",\n647:     \"block_reason\": block_reason or None,\n648:     \"execution_started\": run_started == \"true\",\n649:     \"change_declared\": change_declared == \"true\",\n650:     \"result_contract_valid\": result_contract_valid == \"true\",\n651:     \"result_contract_status\": (\n652:         None\n653:         if contract_status in {\"\", \"UNKNOWN\", \"NOT_APPLICABLE\"}\n654:         else contract_status\n655:     ),\n656:     \"result_contract_error\": (\n657:         None","context_end":657,"context_start":643,"line":650,"matched":["RESULT_CONTRACT"]},{"context":"644:     \"error_register_sha256\": error_sha,\n645:     \"command_sha256\": command_sha,\n646:     \"duplicate_failed_command_blocked\": repeat_blocked == \"true\",\n647:     \"block_reason\": block_reason or None,\n648:     \"execution_started\": run_started == \"true\",\n649:     \"change_declared\": change_declared == \"true\",\n650:     \"result_contract_valid\": result_contract_valid == \"true\",\n651:     \"result_contract_status\": (\n652:         None\n653:         if contract_status in {\"\", \"UNKNOWN\", \"NOT_APPLICABLE\"}\n654:         else contract_status\n655:     ),\n656:     \"result_contract_error\": (\n657:         None\n658:         if result_contract_error == \"NONE\"","context_end":658,"context_start":644,"line":651,"matched":["RESULT_CONTRACT"]},{"context":"649:     \"change_declared\": change_declared == \"true\",\n650:     \"result_contract_valid\": result_contract_valid == \"true\",\n651:     \"result_contract_status\": (\n652:         None\n653:         if contract_status in {\"\", \"UNKNOWN\", \"NOT_APPLICABLE\"}\n654:         else contract_status\n655:     ),\n656:     \"result_contract_error\": (\n657:         None\n658:         if result_contract_error == \"NONE\"\n659:         else result_contract_error\n660:     ),\n661:     \"command_rc\": int(command_rc) if command_rc else None,\n662:     \"changes_made\": optional_bool(changes_made),\n663:     \"rollback_started\": optional_bool(rollback_started),","context_end":663,"context_start":649,"line":656,"matched":["RESULT_CONTRACT"]},{"context":"651:     \"result_contract_status\": (\n652:         None\n653:         if contract_status in {\"\", \"UNKNOWN\", \"NOT_APPLICABLE\"}\n654:         else contract_status\n655:     ),\n656:     \"result_contract_error\": (\n657:         None\n658:         if result_contract_error == \"NONE\"\n659:         else result_contract_error\n660:     ),\n661:     \"command_rc\": int(command_rc) if command_rc else None,\n662:     \"changes_made\": optional_bool(changes_made),\n663:     \"rollback_started\": optional_bool(rollback_started),\n664:     \"rollback_restored\": optional_bool(rollback_restored),\n665:     \"mutation_outcome\": mutation_outcome,","context_end":665,"context_start":651,"line":658,"matched":["RESULT_CONTRACT"]},{"context":"652:         None\n653:         if contract_status in {\"\", \"UNKNOWN\", \"NOT_APPLICABLE\"}\n654:         else contract_status\n655:     ),\n656:     \"result_contract_error\": (\n657:         None\n658:         if result_contract_error == \"NONE\"\n659:         else result_contract_error\n660:     ),\n661:     \"command_rc\": int(command_rc) if command_rc else None,\n662:     \"changes_made\": optional_bool(changes_made),\n663:     \"rollback_started\": optional_bool(rollback_started),\n664:     \"rollback_restored\": optional_bool(rollback_restored),\n665:     \"mutation_outcome\": mutation_outcome,\n666:     \"sanitized\": True,","context_end":666,"context_start":652,"line":659,"matched":["RESULT_CONTRACT"]},{"context":"654:         else contract_status\n655:     ),\n656:     \"result_contract_error\": (\n657:         None\n658:         if result_contract_error == \"NONE\"\n659:         else result_contract_error\n660:     ),\n661:     \"command_rc\": int(command_rc) if command_rc else None,\n662:     \"changes_made\": optional_bool(changes_made),\n663:     \"rollback_started\": optional_bool(rollback_started),\n664:     \"rollback_restored\": optional_bool(rollback_restored),\n665:     \"mutation_outcome\": mutation_outcome,\n666:     \"sanitized\": True,\n667:     \"secrets_included\": False,\n668:     \"private_addresses_included\": False,","context_end":668,"context_start":654,"line":661,"matched":["COMMAND_RC"]},{"context":"665:     \"mutation_outcome\": mutation_outcome,\n666:     \"sanitized\": True,\n667:     \"secrets_included\": False,\n668:     \"private_addresses_included\": False,\n669:     \"raw_evidence_retained_locally\": True,\n670:     \"raw_evidence_sha256\": raw_sha,\n671:     \"sanitized_output_sha256\": sanitized_sha,\n672:     \"output_truncated_in_json\": output_truncated,\n673:     \"full_sanitized_output_url\": (\n674:         \"https://git.gram1.ru/.well-known/\"\n675:         \"homelab-runtime/latest.txt\"\n676:     ),\n677:     \"output\": output_preview,\n678: }\n679: ","context_end":679,"context_start":665,"line":672,"matched":["output_truncated_in_json"]},{"context":"666:     \"sanitized\": True,\n667:     \"secrets_included\": False,\n668:     \"private_addresses_included\": False,\n669:     \"raw_evidence_retained_locally\": True,\n670:     \"raw_evidence_sha256\": raw_sha,\n671:     \"sanitized_output_sha256\": sanitized_sha,\n672:     \"output_truncated_in_json\": output_truncated,\n673:     \"full_sanitized_output_url\": (\n674:         \"https://git.gram1.ru/.well-known/\"\n675:         \"homelab-runtime/latest.txt\"\n676:     ),\n677:     \"output\": output_preview,\n678: }\n679: \n680: Path(json_path).write_text(","context_end":680,"context_start":666,"line":673,"matched":["full_sanitized_output_url"]},{"context":"668:     \"private_addresses_included\": False,\n669:     \"raw_evidence_retained_locally\": True,\n670:     \"raw_evidence_sha256\": raw_sha,\n671:     \"sanitized_output_sha256\": sanitized_sha,\n672:     \"output_truncated_in_json\": output_truncated,\n673:     \"full_sanitized_output_url\": (\n674:         \"https://git.gram1.ru/.well-known/\"\n675:         \"homelab-runtime/latest.txt\"\n676:     ),\n677:     \"output\": output_preview,\n678: }\n679: \n680: Path(json_path).write_text(\n681:     json.dumps(\n682:         document,","context_end":682,"context_start":668,"line":675,"matched":["homelab-runtime","latest"]},{"context":"700:     echo \"REFERENCE_SHA256=$REFERENCE_SHA256\"\n701:     echo 'ERROR_REGISTER_CHECK=OK'\n702:     echo \"ERROR_REGISTER_SHA256=$ERROR_REGISTER_SHA256\"\n703:     echo \"COMMAND_SHA256=$COMMAND_SHA256\"\n704:     echo \"DUPLICATE_FAILED_COMMAND_BLOCKED=$REPEAT_BLOCKED\"\n705:     echo \"EXECUTION_STARTED=$RUN_STARTED\"\n706:     echo \"CHANGE_DECLARED=$CHANGE_DECLARED\"\n707:     echo \"RESULT_CONTRACT_VALID=$RESULT_CONTRACT_VALID\"\n708:     echo \"RESULT_CONTRACT_STATUS=$CONTRACT_STATUS\"\n709:     echo \"RESULT_CONTRACT_ERROR=$RESULT_CONTRACT_ERROR\"\n710:     echo \"COMMAND_RC=${COMMAND_RC:-}\"\n711:     echo \"CHANGES_MADE=$CHANGES_MADE\"\n712:     echo \"ROLLBACK_STARTED=$ROLLBACK_STARTED\"\n713:     echo \"ROLLBACK_RESTORED=$ROLLBACK_RESTORED\"\n714:     echo \"MUTATION_OUTCOME=$MUTATION_OUTCOME\"","context_end":714,"context_start":700,"line":707,"matched":["RESULT_CONTRACT"]},{"context":"701:     echo 'ERROR_REGISTER_CHECK=OK'\n702:     echo \"ERROR_REGISTER_SHA256=$ERROR_REGISTER_SHA256\"\n703:     echo \"COMMAND_SHA256=$COMMAND_SHA256\"\n704:     echo \"DUPLICATE_FAILED_COMMAND_BLOCKED=$REPEAT_BLOCKED\"\n705:     echo \"EXECUTION_STARTED=$RUN_STARTED\"\n706:     echo \"CHANGE_DECLARED=$CHANGE_DECLARED\"\n707:     echo \"RESULT_CONTRACT_VALID=$RESULT_CONTRACT_VALID\"\n708:     echo \"RESULT_CONTRACT_STATUS=$CONTRACT_STATUS\"\n709:     echo \"RESULT_CONTRACT_ERROR=$RESULT_CONTRACT_ERROR\"\n710:     echo \"COMMAND_RC=${COMMAND_RC:-}\"\n711:     echo \"CHANGES_MADE=$CHANGES_MADE\"\n712:     echo \"ROLLBACK_STARTED=$ROLLBACK_STARTED\"\n713:     echo \"ROLLBACK_RESTORED=$ROLLBACK_RESTORED\"\n714:     echo \"MUTATION_OUTCOME=$MUTATION_OUTCOME\"\n715:     echo 'SANITIZED=yes'","context_end":715,"context_start":701,"line":708,"matched":["RESULT_CONTRACT"]},{"context":"702:     echo \"ERROR_REGISTER_SHA256=$ERROR_REGISTER_SHA256\"\n703:     echo \"COMMAND_SHA256=$COMMAND_SHA256\"\n704:     echo \"DUPLICATE_FAILED_COMMAND_BLOCKED=$REPEAT_BLOCKED\"\n705:     echo \"EXECUTION_STARTED=$RUN_STARTED\"\n706:     echo \"CHANGE_DECLARED=$CHANGE_DECLARED\"\n707:     echo \"RESULT_CONTRACT_VALID=$RESULT_CONTRACT_VALID\"\n708:     echo \"RESULT_CONTRACT_STATUS=$CONTRACT_STATUS\"\n709:     echo \"RESULT_CONTRACT_ERROR=$RESULT_CONTRACT_ERROR\"\n710:     echo \"COMMAND_RC=${COMMAND_RC:-}\"\n711:     echo \"CHANGES_MADE=$CHANGES_MADE\"\n712:     echo \"ROLLBACK_STARTED=$ROLLBACK_STARTED\"\n713:     echo \"ROLLBACK_RESTORED=$ROLLBACK_RESTORED\"\n714:     echo \"MUTATION_OUTCOME=$MUTATION_OUTCOME\"\n715:     echo 'SANITIZED=yes'\n716:     echo 'SECRETS_INCLUDED=no'","context_end":716,"context_start":702,"line":709,"matched":["RESULT_CONTRACT"]},{"context":"703:     echo \"COMMAND_SHA256=$COMMAND_SHA256\"\n704:     echo \"DUPLICATE_FAILED_COMMAND_BLOCKED=$REPEAT_BLOCKED\"\n705:     echo \"EXECUTION_STARTED=$RUN_STARTED\"\n706:     echo \"CHANGE_DECLARED=$CHANGE_DECLARED\"\n707:     echo \"RESULT_CONTRACT_VALID=$RESULT_CONTRACT_VALID\"\n708:     echo \"RESULT_CONTRACT_STATUS=$CONTRACT_STATUS\"\n709:     echo \"RESULT_CONTRACT_ERROR=$RESULT_CONTRACT_ERROR\"\n710:     echo \"COMMAND_RC=${COMMAND_RC:-}\"\n711:     echo \"CHANGES_MADE=$CHANGES_MADE\"\n712:     echo \"ROLLBACK_STARTED=$ROLLBACK_STARTED\"\n713:     echo \"ROLLBACK_RESTORED=$ROLLBACK_RESTORED\"\n714:     echo \"MUTATION_OUTCOME=$MUTATION_OUTCOME\"\n715:     echo 'SANITIZED=yes'\n716:     echo 'SECRETS_INCLUDED=no'\n717:     echo 'PRIVATE_ADDRESSES_INCLUDED=no'","context_end":717,"context_start":703,"line":710,"matched":["COMMAND_RC"]},{"context":"727: chmod 0600 \\\n728:     \"$RAW_FILE\" \\\n729:     \"$SANITIZED_FILE\" \\\n730:     \"$JSON_FILE\" \\\n731:     \"$TXT_FILE\"\n732: \n733: TARGET=debian@[PRIVATE_IP]\n734: REMOTE_PREFIX=\"/tmp/homelab-runtime-${COMMAND_ID}-$$\"\n735: \n736: SSH_OPTS=(\n737:     -o BatchMode=yes\n738:     -o ConnectTimeout=10\n739:     -o ConnectionAttempts=1\n740:     -o StrictHostKeyChecking=yes\n741:     -o UserKnownHostsFile=[SENSITIVE_PATH] REMOTE_PREFIX=\"/tmp/homelab-runtime-${COMMAND_ID}-$$\"\n735: \n736: SSH_OPTS=(\n737:     -o BatchMode=yes\n738:     -o ConnectTimeout=10\n739:     -o ConnectionAttempts=1\n740:     -o StrictHostKeyChecking=yes\n741:     -o UserKnownHostsFile=[SENSITIVE_PATH] )\n743: \n744: scp \\\n745:     -q \\\n746:     \"${SSH_OPTS[@]}\" \\\n747:     \"$JSON_FILE\" \\\n748:     \"${TARGET}:${REMOTE_PREFIX}.json\"","context_end":748,"context_start":734,"line":741,"matched":["ssh\\b"]},{"context":"737:     -o BatchMode=yes\n738:     -o ConnectTimeout=10\n739:     -o ConnectionAttempts=1\n740:     -o StrictHostKeyChecking=yes\n741:     -o UserKnownHostsFile=[SENSITIVE_PATH] )\n743: \n744: scp \\\n745:     -q \\\n746:     \"${SSH_OPTS[@]}\" \\\n747:     \"$JSON_FILE\" \\\n748:     \"${TARGET}:${REMOTE_PREFIX}.json\"\n749: \n750: scp \\\n751:     -q \\","context_end":751,"context_start":737,"line":744,"matched":["scp\\b"]},{"context":"743: \n744: scp \\\n745:     -q \\\n746:     \"${SSH_OPTS[@]}\" \\\n747:     \"$JSON_FILE\" \\\n748:     \"${TARGET}:${REMOTE_PREFIX}.json\"\n749: \n750: scp \\\n751:     -q \\\n752:     \"${SSH_OPTS[@]}\" \\\n753:     \"$TXT_FILE\" \\\n754:     \"${TARGET}:${REMOTE_PREFIX}.txt\"\n755: \n756: ssh \"${SSH_OPTS[@]}\" \"$TARGET\" \"\n757:     set +e","context_end":757,"context_start":743,"line":750,"matched":["scp\\b"]},{"context":"749: \n750: scp \\\n751:     -q \\\n752:     \"${SSH_OPTS[@]}\" \\\n753:     \"$TXT_FILE\" \\\n754:     \"${TARGET}:${REMOTE_PREFIX}.txt\"\n755: \n756: ssh \"${SSH_OPTS[@]}\" \"$TARGET\" \"\n757:     set +e\n758: \n759:     sudo -n /usr/local/sbin/homelab-runtime-receive \\\n760:         '$COMMAND_ID' \\\n761:         '${REMOTE_PREFIX}.json' \\\n762:         '${REMOTE_PREFIX}.txt'\n763: ","context_end":763,"context_start":749,"line":756,"matched":["ssh\\b"]},{"context":"752:     \"${SSH_OPTS[@]}\" \\\n753:     \"$TXT_FILE\" \\\n754:     \"${TARGET}:${REMOTE_PREFIX}.txt\"\n755: \n756: ssh \"${SSH_OPTS[@]}\" \"$TARGET\" \"\n757:     set +e\n758: \n759:     sudo -n /usr/local/sbin/homelab-runtime-receive \\\n760:         '$COMMAND_ID' \\\n761:         '${REMOTE_PREFIX}.json' \\\n762:         '${REMOTE_PREFIX}.txt'\n763: \n764:     receiver_rc=\\$?\n765: \n766:     rm -f \\","context_end":766,"context_start":752,"line":759,"matched":["homelab-runtime"]},{"context":"763: \n764:     receiver_rc=\\$?\n765: \n766:     rm -f \\\n767:         '${REMOTE_PREFIX}.json' \\\n768:         '${REMOTE_PREFIX}.txt'\n769: \n770:     exit \\$receiver_rc\n771: \"\n772: \n773: PUBLIC_URL='https://git.gram1.ru/.well-known/homelab-runtime/latest.json'\n774: PUBLIC_VISIBLE=false\n775: \n776: for ATTEMPT in $(seq 1 30); do\n777:     CONTENT=\"$(","context_end":777,"context_start":763,"line":770,"matched":["exit\\b"]},{"context":"766:     rm -f \\\n767:         '${REMOTE_PREFIX}.json' \\\n768:         '${REMOTE_PREFIX}.txt'\n769: \n770:     exit \\$receiver_rc\n771: \"\n772: \n773: PUBLIC_URL='https://git.gram1.ru/.well-known/homelab-runtime/latest.json'\n774: PUBLIC_VISIBLE=false\n775: \n776: for ATTEMPT in $(seq 1 30); do\n777:     CONTENT=\"$(\n778:         curl -fsS \\\n779:             --max-time 15 \\\n780:             \"$PUBLIC_URL\" 2>/dev/null ||","context_end":780,"context_start":766,"line":773,"matched":["homelab-runtime","latest"]},{"context":"771: \"\n772: \n773: PUBLIC_URL='https://git.gram1.ru/.well-known/homelab-runtime/latest.json'\n774: PUBLIC_VISIBLE=false\n775: \n776: for ATTEMPT in $(seq 1 30); do\n777:     CONTENT=\"$(\n778:         curl -fsS \\\n779:             --max-time 15 \\\n780:             \"$PUBLIC_URL\" 2>/dev/null ||\n781:         true\n782:     )\"\n783: \n784:     if printf '%s\\n' \"$CONTENT\" |\n785:        grep -Fq \"\\\"command_id\\\": \\\"$COMMAND_ID\\\"\"; then","context_end":785,"context_start":771,"line":778,"matched":["curl\\b"]},{"context":"791: done\n792: \n793: if [ \"$PUBLIC_VISIBLE\" != true ]; then\n794:     echo 'RESULT=FAIL'\n795:     echo 'REASON=PUBLIC_RUNTIME_RESULT_NOT_VISIBLE'\n796:     echo \"COMMAND_ID=$COMMAND_ID\"\n797:     echo \"LOCAL_RAW_FILE=$RAW_FILE\"\n798:     exit 75\n799: fi\n800: \n801: printf '%s\\t%s\\t%s\\t%s\\t%s\\t%s\\n' \\\n802:     \"$FINISHED_AT\" \\\n803:     \"$COMMAND_ID\" \\\n804:     \"$COMMAND_SHA256\" \\\n805:     \"$RC\" \\","context_end":805,"context_start":791,"line":798,"matched":["exit\\b"]},{"context":"815: echo 'ERROR_REGISTER_CHECK=OK'\n816: echo \"DUPLICATE_FAILED_COMMAND_BLOCKED=$REPEAT_BLOCKED\"\n817: echo 'GITEA_PUBLICATION=OK'\n818: echo \"PUBLIC_URL=$PUBLIC_URL\"\n819: echo \"LOCAL_RAW_FILE=$RAW_FILE\"\n820: echo 'SHELL_SESSION_PRESERVED=yes'\n821: \n822: exit \"$RC\"","context_end":822,"context_start":815,"line":822,"matched":["exit\\b"]}],"matches_truncated":false,"path":"/usr/local/sbin/homelab-chat-run","sha256":"b248a4c32c9cc64e5747e7dce6c7fc0a23f5124a77c71ce72e27a81aceae9d2d","size":21321,"tail":"703:     echo \"COMMAND_SHA256=$COMMAND_SHA256\"\n704:     echo \"DUPLICATE_FAILED_COMMAND_BLOCKED=$REPEAT_BLOCKED\"\n705:     echo \"EXECUTION_STARTED=$RUN_STARTED\"\n706:     echo \"CHANGE_DECLARED=$CHANGE_DECLARED\"\n707:     echo \"RESULT_CONTRACT_VALID=$RESULT_CONTRACT_VALID\"\n708:     echo \"RESULT_CONTRACT_STATUS=$CONTRACT_STATUS\"\n709:     echo \"RESULT_CONTRACT_ERROR=$RESULT_CONTRACT_ERROR\"\n710:     echo \"COMMAND_RC=${COMMAND_RC:-}\"\n711:     echo \"CHANGES_MADE=$CHANGES_MADE\"\n712:     echo \"ROLLBACK_STARTED=$ROLLBACK_STARTED\"\n713:     echo \"ROLLBACK_RESTORED=$ROLLBACK_RESTORED\"\n714:     echo \"MUTATION_OUTCOME=$MUTATION_OUTCOME\"\n715:     echo 'SANITIZED=yes'\n716:     echo 'SECRETS_INCLUDED=no'\n717:     echo 'PRIVATE_ADDRESSES_INCLUDED=no'\n718:     echo \"RAW_EVIDENCE_SHA256=$RAW_SHA256\"\n719:     echo \"SANITIZED_OUTPUT_SHA256=$SANITIZED_SHA256\"\n720:     echo 'OUTPUT_BEGIN'\n721:     cat \"$SANITIZED_FILE\"\n722:     echo\n723:     echo 'OUTPUT_END'\n724:     echo 'CHAT_OUTPUT_END'\n725: } >\"$TXT_FILE\"\n726: \n727: chmod 0600 \\\n728:     \"$RAW_FILE\" \\\n729:     \"$SANITIZED_FILE\" \\\n730:     \"$JSON_FILE\" \\\n731:     \"$TXT_FILE\"\n732: \n733: TARGET=debian@[PRIVATE_IP]\n734: REMOTE_PREFIX=\"/tmp/homelab-runtime-${COMMAND_ID}-$$\"\n735: \n736: SSH_OPTS=(\n737:     -o BatchMode=yes\n738:     -o ConnectTimeout=10\n739:     -o ConnectionAttempts=1\n740:     -o StrictHostKeyChecking=yes\n741:     -o UserKnownHostsFile=[SENSITIVE_PATH] )\n743: \n744: scp \\\n745:     -q \\\n746:     \"${SSH_OPTS[@]}\" \\\n747:     \"$JSON_FILE\" \\\n748:     \"${TARGET}:${REMOTE_PREFIX}.json\"\n749: \n750: scp \\\n751:     -q \\\n752:     \"${SSH_OPTS[@]}\" \\\n753:     \"$TXT_FILE\" \\\n754:     \"${TARGET}:${REMOTE_PREFIX}.txt\"\n755: \n756: ssh \"${SSH_OPTS[@]}\" \"$TARGET\" \"\n757:     set +e\n758: \n759:     sudo -n /usr/local/sbin/homelab-runtime-receive \\\n760:         '$COMMAND_ID' \\\n761:         '${REMOTE_PREFIX}.json' \\\n762:         '${REMOTE_PREFIX}.txt'\n763: \n764:     receiver_rc=\\$?\n765: \n766:     rm -f \\\n767:         '${REMOTE_PREFIX}.json' \\\n768:         '${REMOTE_PREFIX}.txt'\n769: \n770:     exit \\$receiver_rc\n771: \"\n772: \n773: PUBLIC_URL='https://git.gram1.ru/.well-known/homelab-runtime/latest.json'\n774: PUBLIC_VISIBLE=false\n775: \n776: for ATTEMPT in $(seq 1 30); do\n777:     CONTENT=\"$(\n778:         curl -fsS \\\n779:             --max-time 15 \\\n780:             \"$PUBLIC_URL\" 2>/dev/null ||\n781:         true\n782:     )\"\n783: \n784:     if printf '%s\\n' \"$CONTENT\" |\n785:        grep -Fq \"\\\"command_id\\\": \\\"$COMMAND_ID\\\"\"; then\n786:         PUBLIC_VISIBLE=true\n787:         break\n788:     fi\n789: \n790:     sleep 2\n791: done\n792: \n793: if [ \"$PUBLIC_VISIBLE\" != true ]; then\n794:     echo 'RESULT=FAIL'\n795:     echo 'REASON=PUBLIC_RUNTIME_RESULT_NOT_VISIBLE'\n796:     echo \"COMMAND_ID=$COMMAND_ID\"\n797:     echo \"LOCAL_RAW_FILE=$RAW_FILE\"\n798:     exit 75\n799: fi\n800: \n801: printf '%s\\t%s\\t%s\\t%s\\t%s\\t%s\\n' \\\n802:     \"$FINISHED_AT\" \\\n803:     \"$COMMAND_ID\" \\\n804:     \"$COMMAND_SHA256\" \\\n805:     \"$RC\" \\\n806:     \"$STATUS\" \\\n807:     \"$COMPONENT\" >>\"$LEDGER\"\n808: \n809: echo\n810: echo '===== HOMELAB CHAT RUN COMPLETE ====='\n811: echo \"COMMAND_ID=$COMMAND_ID\"\n812: echo \"STATUS=$STATUS\"\n813: echo \"RC=$RC\"\n814: echo 'REFERENCE_REGISTER_CHECK=OK'\n815: echo 'ERROR_REGISTER_CHECK=OK'\n816: echo \"DUPLICATE_FAILED_COMMAND_BLOCKED=$REPEAT_BLOCKED\"\n817: echo 'GITEA_PUBLICATION=OK'\n818: echo \"PUBLIC_URL=$PUBLIC_URL\"\n819: echo \"LOCAL_RAW_FILE=$RAW_FILE\"\n820: echo 'SHELL_SESSION_PRESERVED=yes'\n821: \n822: exit \"$RC\""},"target_public_files":[{"mode":"0o600","mtime_ns":1785419604443867066,"path":"/var/lib/homelab-chat-run/public/RESULT-ACCESS-IMPLEMENTATION-PROBE-VERIFY-20260730T135111Z-20260730T135320Z-latest.txt","sha256":"9dd01d81311262b00bf577fc66319e65039be9e805f83a20ea397c897fbd2299","size":881082},{"mode":"0o600","mtime_ns":1785419604440890213,"path":"/var/lib/homelab-chat-run/public/RESULT-ACCESS-IMPLEMENTATION-PROBE-VERIFY-20260730T135111Z-20260730T135320Z.json","sha256":"e899abc29cc65ff4082011a35d51bb6be48eec994609021cee8def9d241a144f","size":320855},{"mode":"0o600","mtime_ns":1785419604412866590,"path":"/var/lib/homelab-chat-run/public/RESULT-ACCESS-IMPLEMENTATION-PROBE-VERIFY-20260730T135111Z-20260730T135320Z.txt","sha256":"55bfc6d3ec28b0740361ff4dc0a0fde46d360ab4decd39899baefd790602e871","size":880069}],"target_raw_files":[{"mode":"0o600","mtime_ns":1785419603666855142,"path":"/var/lib/homelab-chat-run/raw/RESULT-ACCESS-IMPLEMENTATION-PROBE-VERIFY-20260730T135111Z-20260730T135320Z.log","sha256":"3ad69207236c05b7838a77c6ca20c8608afadca1ff2e448f7b85411498a5b7aa","size":5790188}]},"mutation_outcome":"NO_MUTATION","output_truncated_in_json":false,"rc":0,"read_only":true,"rollback_restored":null,"rollback_started":false,"schema":1,"status":"OK"}

OUTPUT_END
CHAT_OUTPUT_END
