| 1 | // This file holds the words alta-adopt shows or asks Paul to type. They |
| 2 | // go through the copy-review skill before merge (plan Task 14, step 5); |
| 3 | // a change here is a change of copy. |
| 4 | // |
| 5 | // Approved by Paul, 2026-11-16, verbatim: copy review |
| 6 | // 2y3evbm7avhwx5sy6ubygyewae (every string in this file) and the README |
| 7 | // runbook in copy review si53b27d3tasj7si7ubqovkqw4. The strings changed |
| 8 | // for Paul's ruling of 2026-11-17 (Home discussion 103: the delivery check |
| 9 | // replaces the witness, and the live checks are dropped) were approved |
| 10 | // verbatim in copy review 2axwfwbh2w5tlh2qaehjutl55a. |
| 11 | package adopt |
| 12 | |
| 13 | import ( |
| 14 | "fmt" |
| 15 | "strings" |
| 16 | ) |
| 17 | |
| 18 | // WriteSummary is configure's dry-run description of the write: the two |
| 19 | // keys and the bundle they are written to, never their values. |
| 20 | func WriteSummary(keys [2]string, bundle string) string { |
| 21 | return "set " + keys[0] + ", " + keys[1] + " on " + bundle |
| 22 | } |
| 23 | |
| 24 | // ---- the alta-adopt command ---- |
| 25 | |
| 26 | // Usage is alta-adopt's help: what it prints with no command, with help, |
| 27 | // or with a command it does not know. |
| 28 | // |
| 29 | // The witness and live lines are gone, and the |
| 30 | // --carlos-token-fd line no longer names witness. |
| 31 | const Usage = `alta-adopt adopts the Oficina apps into the Oficina team at Home. |
| 32 | |
| 33 | Usage: |
| 34 | alta-adopt <command> --config <file> [flags] |
| 35 | |
| 36 | Without --apply, a command shows what it would do and writes nothing, |
| 37 | anywhere. |
| 38 | |
| 39 | Commands, in the order of a run: |
| 40 | home-preflight --phase pre-initialize|pre-plan-a |
| 41 | check Home before initialize or before Plan A |
| 42 | preflight [--app <app>] check each app's CARLOS configuration (never writes) |
| 43 | initialize open Home's initialize plan on the directory |
| 44 | plan-a open Plan A: seed the team, then provision and |
| 45 | register the apps |
| 46 | advance --run <id> take a run as far as it can go now |
| 47 | configure --app <app> write the app's two agent keys, restart it and |
| 48 | check it |
| 49 | activate --apps <list> open Plan B (calendar) or Plan C (the other apps) |
| 50 | rollback-config --app <app> |
| 51 | remove the app's two agent keys and restart it |
| 52 | disable --app <app> disable the app's team binding at Home |
| 53 | status show where the adoption is (never writes) |
| 54 | version print the version |
| 55 | |
| 56 | Flags: |
| 57 | --config <file> the configuration file: mode 0600, owned by you |
| 58 | --carlos-token-fd <n> read the CARLOS Admin token from file |
| 59 | descriptor n (3 or above); configure, activate, |
| 60 | rollback-config, preflight and the advance of |
| 61 | Plans B and C need it |
| 62 | --apply do it |
| 63 | ` |
| 64 | |
| 65 | // What the command says. Values are app slugs, hosts, run ids, states |
| 66 | // and fixed codes, never a secret, a value or an address. |
| 67 | const ( |
| 68 | SayDryRun = "Dry run: nothing was written. Run it again with --apply to do it." |
| 69 | SayDone = "Done." |
| 70 | |
| 71 | SayHomeQueries = "Run each query against Home with carlos db query (it only reads), and type the count it answers." |
| 72 | SayHomeReady = "Home is as this phase needs it." |
| 73 | |
| 74 | SayInitializeWould = "This opens Home's initialize plan on the directory. With --apply you will be asked to type this sentence:" |
| 75 | SayInitializeType = "Type this sentence, exactly, if it is true:" |
| 76 | |
| 77 | SayPlanAWould = "This opens Plan A on both roles: the Oficina team, then each app's provision and register. With --apply you will be asked for the owner's address." |
| 78 | SayPlanAOwner = "Type the owner's address, as they sign in at Home:" |
| 79 | |
| 80 | SayAdvanceWould = "With --apply this takes the run as far as it can go now." |
| 81 | |
| 82 | SayDisableAsk = "With --apply you will be asked to type the team's label." |
| 83 | ) |
| 84 | |
| 85 | // SayHomeQuery asks for one count. |
| 86 | func SayHomeQuery(query string) string { return query + "\ncount: " } |
| 87 | |
| 88 | // SayHomeRefused lists what the Home preflight found wrong. |
| 89 | func SayHomeRefused(codes []string) string { |
| 90 | return "Home is not as this phase needs it: " + strings.Join(codes, ", ") |
| 91 | } |
| 92 | |
| 93 | // SayPlanAContinue is plan-a once the team is seeded. |
| 94 | func SayPlanAContinue(apps []string) string { |
| 95 | return "The team is seeded. This continues Plan A for the apps not yet registered: " + strings.Join(apps, ", ") + "." |
| 96 | } |
| 97 | |
| 98 | // SayPlanAResubmit is plan-a when Plan A's plan lapsed before the seed. |
| 99 | const SayPlanAResubmit = "Plan A's plan lapsed before the team was seeded. This signs it again." |
| 100 | |
| 101 | // SayRun is a run's state. |
| 102 | func SayRun(id int64, state, code string) string { |
| 103 | return strings.TrimSpace(fmt.Sprintf("Run %d: %s %s", id, state, code)) |
| 104 | } |
| 105 | |
| 106 | // SayConfirm is what Paul does after a plan is opened: confirm it on |
| 107 | // Home's pages for roles, then advance the run. |
| 108 | func SayConfirm(id int64, roles []string) string { |
| 109 | pages := "directory" |
| 110 | if len(roles) > 1 { |
| 111 | pages = "directory and credential" |
| 112 | } |
| 113 | return fmt.Sprintf("Run %d opened. Confirm it on Home's %s confirm pages, then run:\n alta-adopt advance --run %d --apply", id, pages, id) |
| 114 | } |
| 115 | |
| 116 | // SayConfigureWould is configure's dry run after the write's summary. |
| 117 | func SayConfigureWould(host string) string { |
| 118 | return "Then it restarts " + host + " alone, waits for it to serve the new configuration, and checks that it still serves the reviewed release." |
| 119 | } |
| 120 | |
| 121 | // SayConfigured is a finished configure, its delivery check recorded. |
| 122 | func SayConfigured(host string) string { |
| 123 | return host + " restarted on the new configuration, and nothing else changed. It still serves the reviewed release and now answers agent requests. Delivery check recorded." |
| 124 | } |
| 125 | |
| 126 | // SayActivateApp is one app's readiness for activation. |
| 127 | func SayActivateApp(app string, codes []string) string { |
| 128 | if len(codes) == 0 { |
| 129 | return app + ": ready" |
| 130 | } |
| 131 | return app + ": refused: " + strings.Join(codes, ", ") |
| 132 | } |
| 133 | |
| 134 | // SayActivateWould is activate's dry run. |
| 135 | func SayActivateWould(apps []string) string { |
| 136 | return "With --apply this opens an add-apps plan on both roles for: " + strings.Join(apps, ", ") + "." |
| 137 | } |
| 138 | |
| 139 | // SayRolledBack is a finished rollback. |
| 140 | func SayRolledBack(host string) string { |
| 141 | return host + ": both agent keys removed, and the app restarted on its previous configuration." |
| 142 | } |
| 143 | |
| 144 | // SayRollbackWould is rollback-config's dry run when both agent keys are |
| 145 | // still in place: which keys go, from which bundle, and which host |
| 146 | // restarts. |
| 147 | func SayRollbackWould(keys [2]string, bundle, host string) string { |
| 148 | return "This removes " + keys[0] + " and " + keys[1] + " from " + bundle + ", then restarts " + host + " alone and waits for it to serve its previous configuration." |
| 149 | } |
| 150 | |
| 151 | // SayRollbackRestartOnly is rollback-config's dry run when the keys are |
| 152 | // already gone but the restart has not been seen through. |
| 153 | func SayRollbackRestartOnly(keys [2]string, host string) string { |
| 154 | return keys[0] + " and " + keys[1] + " are already removed. This restarts " + host + " alone and waits for it to serve its previous configuration." |
| 155 | } |
| 156 | |
| 157 | // SayRollbackNothing is rollback-config once the rollback is complete. |
| 158 | func SayRollbackNothing(host string) string { |
| 159 | return host + " is already rolled back. There is nothing to do." |
| 160 | } |
| 161 | |
| 162 | // SayDisableType is disable's prompt. |
| 163 | func SayDisableType(app string) string { |
| 164 | return "This disables " + app + "'s team binding at Home. Type the team's label to go on:" |
| 165 | } |
| 166 | |
| 167 | // SayDisableWould is disable's dry run. |
| 168 | func SayDisableWould(app string) string { |
| 169 | return "This opens a plan on the directory to disable " + app + "'s team binding at Home." |
| 170 | } |
| 171 | |
| 172 | // SayStatusTeam is the team's state. |
| 173 | func SayStatusTeam(seeded bool) string { |
| 174 | if seeded { |
| 175 | return "Team: seeded" |
| 176 | } |
| 177 | return "Team: not seeded" |
| 178 | } |
| 179 | |
| 180 | // SayStatusPreflight is one Home preflight's state. |
| 181 | func SayStatusPreflight(phase string, recorded bool) string { |
| 182 | if recorded { |
| 183 | return "Home preflight " + phase + ": recorded" |
| 184 | } |
| 185 | return "Home preflight " + phase + ": not recorded" |
| 186 | } |
| 187 | |
| 188 | // SayStatusApp is one app's line: its Home steps and its journal. |
| 189 | func SayStatusApp(app string, parts []string) string { |
| 190 | return app + ": " + strings.Join(parts, ", ") |
| 191 | } |
| 192 | |
| 193 | // SayStatusNothing is an app with no step and no journal yet. |
| 194 | const SayStatusNothing = "not started" |
| 195 | |
| 196 | // SayStatusDeliveryCheck is an app's journal part once its delivery check |
| 197 | // is recorded. |
| 198 | const SayStatusDeliveryCheck = "delivery-check" |
| 199 | |
| 200 | // The command's refusals before it reaches anything: its flags, its |
| 201 | // config file and the token's descriptor. They name fields and flags, |
| 202 | // never a value. |
| 203 | const ( |
| 204 | RefuseFlag = "not a flag this command takes" |
| 205 | RefuseConfigMissing = "--config is required" |
| 206 | RefuseConfigOpen = "the config file does not open" |
| 207 | RefuseConfigRegular = "the config file is not a regular file" |
| 208 | RefuseConfigMode = "the config file must be mode 0600" |
| 209 | RefuseConfigOwner = "the config file must be owned by you" |
| 210 | RefuseConfigRead = "the config file does not read" |
| 211 | RefuseConfigJSON = "the config file is not the expected JSON" |
| 212 | RefuseTokenFD = "--carlos-token-fd must name a descriptor of 3 or above" |
| 213 | RefuseTokenFDClosed = "--carlos-token-fd does not name an open descriptor" |
| 214 | RefuseTokenFDRead = "--carlos-token-fd does not read" |
| 215 | RefuseTokenLong = "the CARLOS token is too long" |
| 216 | RefuseTokenEmpty = "the CARLOS token is empty" |
| 217 | RefuseStateOpen = "the state database does not open" |
| 218 | RefuseNoJournalBase = "the journal has a write and no baseline" |
| 219 | RefuseConsoleReached = "an adoption run reached for the console" |
| 220 | ) |
| 221 | |
| 222 | // RefuseConfigField is a config field that is missing or malformed. |
| 223 | func RefuseConfigField(field string) string { |
| 224 | return "the config's " + field + " is missing or malformed" |
| 225 | } |
| 226 | |
| 227 | // Hints that follow a refusal, telling Paul what comes first. |
| 228 | const ( |
| 229 | HintPreInitialize = "Run alta-adopt home-preflight --phase pre-initialize --apply first." |
| 230 | HintPrePlanA = "Run alta-adopt home-preflight --phase pre-plan-a --apply first." |
| 231 | HintToken = "This command reads CARLOS: pass the Admin token with --carlos-token-fd." |
| 232 | HintCanary = "Activate calendar first: alta-adopt activate --apps calendar --apply." |
| 233 | ) |
| 234 | |