| new file mode 100644 |
| index 000000000..6c4e88b1b |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/named-units-param-114-copy-deck.md |
| @@ -0,0 +1,95 @@ |
| +# Named units from a parameter: copy deck (branch named-units-param-114) |
| + |
| +Feature: an operator writes a fixed box's named-unit declarations to an AWS SSM parameter, /carlos/host/named-units/<instance-id>, from their own machine; root on the box installs it on its next config pass and reports what it did through the heartbeat. Readers: platform operators in a terminal. |
| +Placeholders in <angle brackets> must survive. CLI output is plain ASCII. |
| + |
| +## CLI help (carlos system named-units) |
| +| id | context | text | |
| +|---|---|---| |
| +| NU-H01 | group usage, `named-units help` | usage: carlos system named-units install <file> / carlos system named-units put --instance <id> [--aws-region <region>] <file> / carlos system named-units show --instance <id> [--aws-region <region>] | |
| +| NU-H02 | help line for install | install <file> as this box's /etc/carlos/named-units.json. Run it on the box, as root. | |
| +| NU-H03 | help line for put | check <file>, then write it to the box's parameter, /carlos/host/named-units/<id>, with your AWS profile. | |
| +| NU-H04 | help line for show | print the box's parameter and what the box last reported. | |
| +| NU-H05 | --instance flag help | the box's EC2 instance ID, such as i-0abc1234def567890 (required) | |
| +| NU-H06 | --aws-region flag help | the AWS region the box runs in (default: your AWS profile's region) | |
| +| NU-H07 | --console flag help (show) | console to read the box's report from (default: the only logged-in one) | |
| +| NU-H08 | `carlos system` help section heading | A fixed box's named units (see carlos system named-units help): | |
| +| NU-H09 | `carlos system` help line | named-units install install a declaration file on the box (root) | |
| +| NU-H10 | `carlos system` help line | named-units put write a box's declarations to its parameter | |
| +| NU-H11 | `carlos system` help line | named-units show the box's parameter, and what the box last reported | |
| + |
| +## CLI: put output |
| +| id | context | text | |
| +|---|---|---| |
| +| NU-P01 | success, first line | wrote <param> (version <n>) in <region> | |
| +| NU-P02 | success, second line: when the box picks it up | The box installs it on its next config pass (any config write to an app on that box starts one) or within the hour. | |
| +| NU-P03 | success, third line | To check: carlos system named-units show --instance <id> --aws-region <region> | |
| +| NU-P04 | error: file invalid (prefixed "carlos system named-units put: ") | <file>: <validation error>. Nothing was written | |
| +| NU-P05 | error: AWS open failed | AWS: <err>. Nothing was written | |
| +| NU-P06 | error: put failed | writing <param>: <err> | |
| +| NU-P07 | error: bad instance id | --instance "<x>" is not an EC2 instance ID | |
| +| NU-P08 | usage errors | --instance is required / put takes one file / show takes no arguments | |
| + |
| +## CLI: show output |
| +| id | context | text | |
| +|---|---|---| |
| +| NU-S01 | parameter line | parameter <param> version <n> in <region> | |
| +| NU-S02 | no parameter | parameter <param> in <region>: no value stored | |
| +| NU-S03 | read failed | parameter <param> in <region>: could not be read: <err> | |
| +| NU-S04 | console unreachable | box report unavailable: <err> | |
| +| NU-S05 | no row for the instance | No box has reported instance <id> to this console. The box may be down, on another console, or on a release from before named-units reports. | |
| +| NU-S06 | box line | box <label>, last heartbeat <age> ago | |
| +| NU-S07 | appended when stale | (stale: the box may be down) | |
| +| NU-S08 | box has no record | The box has not reported a named-units record. Its release may be from before named-units reports, or its first pass has not run yet. | |
| +| NU-S09 | region mismatch | The box reads its parameter in <box region>, and this one is in <region>. Write it there with --aws-region <box region>. | |
| +| NU-S10 | box behind | The box has not taken version <n> yet: it last read version <m>, and its last heartbeat was <age> ago. | |
| +| NU-S11 | exit error | carlos system named-units show: the parameter could not be read | |
| +| NU-S12 | direct mode error | this shell is in direct bucket mode (CARLOS_DEPLOYMENT_BUCKET or CARLOS_DEPLOYMENT_DIR is set), and box reports come from a console | |
| +| NU-G01 | outcome gloss installed | the box installed this version | |
| +| NU-G02 | outcome gloss unchanged | the box already had this version installed | |
| +| NU-G03 | outcome gloss not-found | the box found no parameter at its path | |
| +| NU-G04 | outcome gloss unreadable | the box could not read the parameter | |
| +| NU-G05 | outcome gloss invalid | the box refused the value and kept its installed file | |
| +| NU-G06 | outcome gloss held | a rollback in progress needs the current file, so the box will try again next pass | |
| +| NU-G07 | outcome gloss skipped | this box does not take declarations from a parameter | |
| +| NU-G08 | outcome gloss failed | the box could not install the file | |
| + |
| +## Reasons root records (shown by `show` as "reason", and in the box journal) |
| +| id | context | text | |
| +|---|---|---| |
| +| NU-R01 | not found | named-units: no parameter <param>; the installed declarations stand | |
| +| NU-R02 | unreadable | named-units: parameter <param> unreadable: <err>; the installed declarations stand | |
| +| NU-R03 | held | a recorded rollback of <host> needs the current declarations | |
| +| NU-R04 | held, check failed | cannot tell whether a recorded rollback of <host> needs the current declarations: <err> | |
| +| NU-R05 | held, current file unreadable | cannot read the installed file <path>: <err> | |
| +| NU-R06 | installed (journal) | named-units: installed <path> version <n> from <param> (sha256 <digest>) | |
| +| NU-R07 | unchanged (journal) | named-units: <param> version <n> unchanged | |
| +| NU-R08 | per-unit refusal, app has no config | no config is set for <account>/<app>, so there is nothing to deliver | |
| + |
| +## Declaration check errors (put and install print these) |
| +| id | context | text | |
| +|---|---|---| |
| +| NU-V01 | too big | named units: file is <n> bytes, the limit is <max> | |
| +| NU-V02 | bad host | named units: host "<host>" is not a valid host name | |
| +| NU-V03 | bad account | named units: host <host>: account "<account>" is not valid | |
| +| NU-V04 | bad app | named units: host <host>: app "<app>" is not valid | |
| +| NU-V05 | missing addr | named units: host <host>: addr is required | |
| +| NU-V06 | missing health | named units: host <host>: health.path is required | |
| +| NU-V07 | missing unit | named units: host <host>: unit is required | |
| +| NU-V08 | bad unit | named units: host <host>: unit "<unit>" is not a valid unit name | |
| +| NU-V09 | carlos-app unit | named units: host <host>: unit "<unit>" is a carlos-app@ unit, which cannot be declared | |
| +| NU-V10 | duplicate host | named units: host <host> is declared twice | |
| +| NU-V11 | duplicate unit | named units: unit <unit> is declared twice | |
| +| NU-V12 | console guard | named units: host <host> is the console guard's host and must be app console, unit console.service, no account | |
| +| NU-V13 | two documents | named units: more than one JSON document | |
| +| NU-V14 | schema | named units: schema must be 1 | |
| + |
| +## Docs: docs/site/cli.md, section "carlos system named-units" (each paragraph is one row) |
| +| id | context | text | |
| +|---|---|---| |
| +| NU-D01 | para 1 | A fixed box's named units, the file `/etc/carlos/named-units.json`, can come from an SSM parameter for that box, so you can change them from your own machine. Root reads `/carlos/host/named-units/<instance-id>` in the box's own AWS region on every config pass. A value is installed only if it passes the same checks as a local install. If the parameter does not exist, the installed file stays as it is. | |
| +| NU-D02 | para 2 | `carlos system named-units put` checks a declaration file, then writes it to the box's parameter with your AWS profile. You need `ssm:PutParameter` on that path, and not root. A file that would fail on the box is refused before anything is written. `--aws-region` must be the box's region; without it, your profile's region is used. | |
| +| NU-D03 | para 3 | The box installs it on its next config pass (any config write to an app on that box starts one) or within the hour. To clear a box's units, put `{"schema":1,"units":[]}`. Deleting the parameter does not clear them: the box keeps the file it has. | |
| +| NU-D04 | para 4 | `carlos system named-units show` prints the stored value and its version, then what the box last reported in its heartbeat: the version it read, what it did with it, and each unit's delivery state. The box report comes through the console, so you need to be logged in as a system operator. Without a console, `show` still prints the parameter and says why the box report is missing. It also says when the box reads another region, or has not yet taken the stored version. | |
| +| NU-D05 | para 5 | `carlos system named-units install <file>` installs the file on the box directly. Use it for boxes set up without a parameter, and during provisioning. It runs as root only. It checks the file first (schema 1, one JSON document, one line per host and per unit, as shown under `carlos route`), then replaces the live file in one step while holding the lock the config pass holds, so a pass never sees half a change. Editing the file by hand while carlos runs is not supported, and a pass that sees the file change under it does nothing and says so. | |
| +| NU-D06 | parity row | A fixed box's named-unit declarations, through its parameter. | |