Complete the header template across Partnership, Kernel, Deployment and Plugin

Finishes the pass: every script now documents its safeguards, and the deliberate absences
in the sourced libraries are recorded so they are not "corrected" later.
This commit is contained in:
Gmer4Lfe
2026-08-01 22:44:23 -04:00
parent 5c4f8db497
commit c377ddfcca
24 changed files with 1237 additions and 32 deletions
+96
View File
@@ -8,6 +8,102 @@
# Removes SSH keys between HOST1 and HOST2 in the specified direction.
# Safe to run at any phase. Clears related setup.db flags.
#
# The escape hatch for a half-finished onboard: partnership setup is multi-phase, and an
# attempt abandoned midway leaves keys installed and phase flags set. This unwinds that so
# onboarding can be started cleanly rather than resumed from an unknown state.
#
# ==============================================================================================
# OPERATIONAL MODEL
# ==============================================================================================
#
# Per direction requested:
#
# h1 (HOST1 → HOST2)
# 1. SSH to HOST2 and delete HOST1's public key line from its authorized_keys
# 2. Clear HOST2's phase / key-ready flags from the setup db
# 3. Delete the local HOST1 key pair
#
# h2 (HOST2 → HOST1)
# Remove HOST2's public key from HOST1's authorized_keys, identifying the key by
# HOST2's hostname in the key comment.
#
# both — run each direction in turn.
#
# Key removal is matched on the key blob or hostname comment, never on line number.
#
# ==============================================================================================
# DESIGN PRINCIPLES
# ==============================================================================================
#
# Safe at Any Phase
# Onboarding is multi-phase and can fail anywhere in it. This runs against whatever state
# exists rather than requiring a known starting point — a missing key or an absent flag is
# a no-op, not an error. Cancelling twice is harmless.
#
# Direction Is Explicit
# Removing a key is not symmetric: it breaks authentication for whichever side loses it.
# The direction must be stated, and defaults to h1 (this host's own outbound key) rather
# than to both, so an unqualified run cannot sever the partner's access to you.
#
# Unwind, Do Not Repair
# The job is to return to a clean pre-onboard state so onboarding can be re-run from the
# top. It deliberately does not attempt to salvage or resume a partial setup — a known
# empty state is worth more than a guessed-at partial one.
#
# Keys and Flags Together
# Removing the key without clearing the setup-db flags would leave onboarding believing a
# phase had completed. Both are cleared in the same pass for that reason.
#
# ==============================================================================================
# OPERATIONAL SAFEGUARDS
# ==============================================================================================
#
# Root Enforcement
# Deletes key pairs from /root/.ssh and edits authorized_keys on both ends as root.
#
# Lock Acquisition
# acquire_lock prevents this racing an in-progress onboard, which would otherwise be
# installing the very keys this is removing.
#
# Host Detection
# detect_hosts() resolves MY_ID / REMOTE_ID so the direction flags map to real hosts.
#
# Direction Default
# Defaults to h1 — never removes the partner's inbound key unless explicitly asked.
#
# Targeted Key Removal
# authorized_keys lines are matched by key blob or hostname comment. Nothing is removed
# positionally, so an unrelated key can never be deleted because it sat on a given line.
#
# SSH Timeout
# The remote edit is wrapped in SSH_TIMEOUT — an unreachable partner fails fast rather
# than hanging a cancel that still has local cleanup to do.
#
# Idempotent
# Absent keys and absent flags are skipped silently. Re-running is safe.
#
# Dry Run Support
# --dry-run reports every key and flag it would remove, and removes none.
#
# ==============================================================================================
# CONFIGURATION
# ==============================================================================================
#
# master.conf
#
# SSH_TIMEOUT
# Bounds the remote authorized_keys edit.
#
# host*.conf
#
# SSH_KEY
# Key used to reach the partner, and the local pair deleted in the h1 direction.
#
# HOST* — hostnames, used to identify which key comment belongs to which side.
#
# Setup state lives in the platform setup db (platform_setup_db_path) — the phase and
# key-ready flags cleared here are the same ones partnership_onboard.sh sets.
#
# ==============================================================================================
# RUNTIME MODES
# ==============================================================================================