design-group-roll-verb
No handoff yet. An agent working here writes one with amadan branch handoff, so that whoever picks the branch up next — a person, or another agent on another machine — can start without reading the whole history.
Recently
<task-notification> <task-id>b3dx2vk39</task-id> <tool-use-id>toolu_017NSYTmhz8xBTEyKRoNxnX5</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/669506ff-23ec-45f1-9035-1d29593f2c37/tasks/b3dx2vk39.output</output-file> <status>completed</status> <summary>Background command "Wait on Astra round 3 by pid" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bp3cf1ywd</task-id> <tool-use-id>toolu_01PRoZ49sqQsRijrQkYkWvTk</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/669506ff-23ec-45f1-9035-1d29593f2c37/tasks/bp3cf1ywd.output</output-file> <status>completed</status> <summary>Background command "Wait on Astra round 2 by pid" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>b2hfj8yp3</task-id> <tool-use-id>toolu_014oz9T3mqdR281JMCC3e8d4</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/669506ff-23ec-45f1-9035-1d29593f2c37/tasks/b2hfj8yp3.output</output-file> <status>completed</status> <summary>Background command "Wait for Astra review to finish" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a893161493e13ba36</task-id> <tool-use-id>toolu_018Gx5Exg5m2cbFXN8XvdaSR</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/669506ff-23ec-45f1-9035-1d29593f2c37/tasks/a893161493e13ba36.output</output-file> <status>completed</status> <summary>Agent "Survey group-maintenance verbs + infra" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>I answered all eight questions from source, with file:line citations; nothing was written or changed. Paths below are relative to the worktree root. ## 1. `carlos system group-maintenance` on the box - **Where it's registered:** `system.go:62-64` registers it as one `raw("group-maintenance", box, …)` leaf (audience `clireg.BoxLocal`) that calls `os.Exit(host.RunGroupMaintenance(args, os.Stdin, os.Stdout, os.Stderr))`. The leaf takes all its arguments at once (comment at `system.go:47-49`). - **Implementation (`internal/host`):** - `group_maintenance_verbs.go`: help text at 21-60, `RunGroupMaintenance` at 64, `run` at 134, status types at 245-301, `status()` at 367, argument parsing in `maintenanceArguments` at 430. - `group_maintenance_prepare.go`: prepare 140, apply 126, rollback 261. - `group_maintenance_drain.go`: drain 72, cancel 154, `handoverStatus` 184. - Also `group_maintenance.go` (permit validation) and `group_maintenance_verbs_linux.go` (lock, permit directory, binary digest, edge process). - **Accepted argument forms:** `prepare --sha256 <64hex>`; bare `status|permit|revoke|apply|rollback`; `drain <txn>`; `drain --cancel <txn>` (becomes `drain-cancel`); `fence-clear <txn>`. A transaction must match `groupTransactionID` and must not start with `-`. - **Exit codes:** 0 ok or help, 1 refused or failed, 2 bad arguments. Errors print as `group-maintenance: …`. - **Root:** `cmd.euid() != 0` returns "root required" (`verbs.go:135`), where euid is `os.Geteuid` (`verbs.go:82`). It also needs the group marker, and takes the apply lock without waiting; a held lock gives "apply lock busy" (`verbs.go:166-169`). `status` can still run when the lock file is missing. - **`status` JSON** (`verbs.go:245-301`, at most 8192 bytes, one line): - Top level: `v` (=1), `iid`, `boot_id`, `account`, `region`, `group`, `config_digest`, `box_ref`. - `edge{state, pid, start_time, started_at, started_at_error, identity, error}`. `identity` is `"<boot_id>:<pid>:<start>"` (`verbs.go:396`). - `binary_sha256` and `binary_error` (both nullable). - `permit{state: absent|present|unknown, transaction, action, expires, consumed, accepted, rollback_consumed, error}`. - `health{state: healthy|unhealthy|unknown, code, error}`, from one GET to `127.0.0.1` + `lbhealth.Path`. - `fence{state, transaction, error}` and `drain{state, incarnation, transaction, step, result, error}`. - **Drain report** (`drainReport`, `internal/host/hadrain.go:124-146`): `v, transaction, incarnation, step (withdraw|move), result (running|ok|failed), reasons[], fence, started_at, finished_at, acked[], moved[{host,holder,gen,confirmed}], released[]/left[] {host,kind,marker,clean,reason}, unclean[], holds, connections_closed_at_bound, quiet`. Drain prints it and exits 0 only when `result=="ok"` (`drain.go:103-113`). Re-running drain joins a move already in progress (`drain.go:83`). ## 2. AWS SDK in Go - **Service modules in `go.mod`:** acm, autoscaling v1.74.0, cloudwatch, costexplorer, ec2 v1.324.0, iam, resourcegroupstaggingapi, route53, s3, sesv2, sqs, ssm v1.74.0, sts (lines 9-21), and sns (line 90). **elasticloadbalancingv2 is not in `go.mod`.** - **`internal/rootaws` exists.** `config.go` provides `LoadDefaultConfig`, which keeps the normal SDK chain for non-root users. For root it disables shared config files and profiles, and refuses `AWS_PROFILE`/`AWS_DEFAULT_PROFILE` (`config.go:52-53, 70-71`). `main.go:25` calls `rootaws.ScrubEnvironment()` for every invocation. - **Packages that build autoscaling, ec2 or ssm clients:** `internal/awsregiongroup/complete.go`, `internal/awsinv/*`, `internal/awsmanaged/*`, `internal/termfence/fence.go`, `internal/boxvolumes/volumes.go`, `internal/host/hatakeover.go`, and `internal/hostenv/awsssm.go`. The last uses `ssm.NewFromConfig` plus GetParametersByPath only (line 63). - **SSM StartSession / session-manager-plugin / SendCommand:** no Go code uses any of them. The only hit is a fake `SendCommand` in `cmd/console/hostsused_scan_test.go:154`. The Python tool shells out to the `aws` CLI with `--profile` (`template_release`, `region-group-roll.py:1087`). ## 3. Provider-neutral import test - `region_ha_boundary_test.go` (repo root): - `TestRegionHACoreImportsNoAWS` (line 76) checks the hand-written list `regionHACoreFiles` (lines 21-44). - `TestRegionHAAdaptersAreNamedForAWS` (line 91) checks that adapter files have AWS in their names. - S3 clients must go through s3compat (lines 158, 181). - The rule is per file, not per package. A new core file has to be added to the list in the same commit. - `internal/registrar/boundary_test.go` is a separate boundary test. ## 4. The command registry and console choice - **The tree:** `commands.go:30` `commandRoot()` → `buildCommandRoot()`; `main.go:35` calls `clireg.Dispatch(commandRoot(), os.Args[1:])`. - **Registry package:** `internal/clireg` (`clireg.go`, `dispatch.go`, `validate.go`). Audiences are `Customer`, `Operator`, `BoxLocal` and `Internal` (`clireg.go:28-31`). - **`carlos system`:** `systemCommand()` at `system.go:50-99` has audience Operator, a transparent `router` child, and Fallback `systemFallback`. `systemGroupCommand()` (`system_roles.go:123`) currently holds only `group role`. Helpers: `raw`, `noHint`, `skipBare`, `skipGolden` in `commands.go:37-60`. - **Console choice:** `config.go:48` `defaultConsole = "https://console.carloku.com"`, and the comment there says it is used by `auth login` only and no other verb assumes it. Operator verbs use `requireDeployAPISession(consoleFlag)` and print the console in use with `printUsing` (e.g. `system_roles.go:136-138`). - **Local AWS profiles:** there is no `--profile` flag or `WithSharedConfigProfile(<name>)` anywhere in the CLI. Grep finds only `""` or test values. There is no `carlos system root` verb. Since `rootaws` refuses profiles when run as root, a port has no existing pattern to follow for operator-side profiles. ## 5. Infra - **`infra/modules/region-host/group_operator.tf`** outputs `group_operator_policy_json` (it creates no IAM resource; empty in fixed mode). Statements: - `GroupMaintenance`: autoscaling UpdateAutoScalingGroup, EnterStandby, ExitStandby on the group ARN, conditioned on the `carlos:deployment` and `carlos:region` resource tags. - `GroupTerminateDrainedMember`: `TerminateInstanceInAutoScalingGroup`, same scoping. - `ObserveMaintenance` on `*`, limited by `aws:RequestedRegion`: DescribeAutoScalingGroups, DescribeAutoScalingInstances, DescribeLifecycleHooks, DescribeScalingActivities, elasticloadbalancing DescribeTargetHealth, ec2 DescribeInstances and DescribeLaunchTemplateVersions, ssm DescribeInstanceInformation. - `GroupSession`: `ssm:StartSession` on `instance/*` where the tag `aws:autoscaling:groupName` equals the group name, plus `BoolIfExists ssm:SessionDocumentAccessCheck=true`. - `ApprovedSessionDocument`: StartSession on the approved document. - `OwnSessions`: Terminate/ResumeSession where the session tag `aws:ssmmessages:session-id` equals `${aws:userid}`. - `OwnSessionDataChannel`: `ssmmessages:OpenDataChannel` on `session/*`. - S3: GetObject on `control/edges/*`; ListBucket with prefix `control/edges/`; lock sweep ListBucket on `<lock_prefix>/` with delimiter `/`, and on `<lock_prefix>/*/lock.json`; GetObject on `…/*/lock.json`. - A precondition requires the document to be `AWS-StartNonInteractiveCommand` or a document owned by this account in this region, and never `SSM-SessionManagerRunShell`. - **Session document:** `infra/modules/region-group-operator-document/main.tf`: - `aws_ssm_document.maintenance`, type Session; the name comes from `var.name`, which may not start with `AWS-`. - `sessionType = "NonInteractiveCommands"`, one String parameter `command` with an `allowedPattern`, and `linux{commands="{{ command }}", runAsElevated=true}`. - The pattern is in `tool-pattern.txt`. It accepts exactly the framed `env -i … /bin/sh -c` wrapper (uid check, `<nonce>:BEGIN`/`END:%s` frames) around the verbs, with timeouts: apply/rollback 900s, drain 3600s, drain --cancel 300s, `systemctl stop carlos-edge` 120s. An optional harness form is added when `harness_bundle_sha256` is set. - **CARLOS_RELEASE:** `group.tf:50` sets `CARLOS_RELEASE = var.group_config.release` inside the templated config, POSIX single-quoted (`group.tf:51`). The template is `group-init.sh.tftpl:4`, and the result is gzipped into user data (`group.tf:53`). The Python tool reads the line back with the regex `^CARLOS_RELEASE='([^']*)'$` (`region-group-roll.py:1081-1100`). ## 6. The census - **What it is:** `AGENTS.md:299-400`. `TestPlan14RootReadCensus` (`internal/provision`) fingerprints the root binary's source. Scope is guarded by `TestCensusScopeIsTheRootBinary`, and each branch has its own `*_census_test.go` cards in `internal/provision/`. - **The Python tool is out of scope:** `AGENTS.md:316-318` lists "Out: … `scripts/`". - **A Go port would be in scope.** Any new package in `go list -deps .` lands in the census, and so does `infra/`. `tool-pattern.txt` is already a census entry (`docs/superpowers/notes/census-proposal-region-ha-held-build.md:33`). ## 7. Release records - `internal/release/layoutintent.go:368` `ParseReleaseVersion`, and `:375` `BelowFloor(version, floor SemVer)`. An unparseable version counts as not below the floor. The Python versions (`release_version` and `below_floor`, `region-group-roll.py:491-502`) say they mirror these. - **Signed pointer:** - `systempointer.go:259` `GetSystemPointer(ctx, store, pub, component, channel)` → `*SystemPointer`. - `Current.Artifacts[platform].SHA256` paired with `Current.Version` is the SHA-to-version link (`SystemRelease` at :62, `SystemArtifact` at :75). - The unexported `verifySystemPointer` is at :217. - **Per-release identity record:** `systemidentity.go:22` `VerifySystemIdentity`, `:45` `IdentityKey(tag)` → `control/system/router/releases/<tag>.json`, `:98` `GetSystemIdentity`, and `:15` `ReleaseTag`. - **How prepare maps a digest to a version today:** `group_maintenance_prepare.go:169-178` checks that the pointer's artifact SHA equals `--sha256`, then takes `p.Current.Version`. The Python tool uses the `version` from prepare's result for its floor check (`region-group-roll.py:1489-1490, 1658`). - **No reverse lookup exists.** Nothing in Go goes from a SHA to a version across past releases. - Related: `internal/hostfloor/floor.go:54` `Verify`. ## 8. Tests for the Python tool | File | Tests | Covers | |---|---|---| | `region_group_roll_test.py` | 110 | Offline witnesses for the attended transaction | | `region_group_held_test.py` | 66 | Planned handovers: replace, remove, drained roll (§25.6/25.9/25.15, H4/H5); a settlement table of more than 30000 rows (:1251) | | `region_group_document_test.py` | 12 | Session grammar acceptance and refusal, seeded `Random(3512)` and `Random(60000)` | | `region_group_probe_test.py` | 28 | Unchanged-member Standby probe | | `region_group_fault_test.py` | 64 | `region-group-fault/fault.py` harness (blocks a member's HTTPS; `bundle.py`, `client.py`, `rehearse.py`) | | `region_group_contract_test.py` | 4 | Audits mock `tofu test` plans | | `check_region_group_plan_test.py` | 49 | Checks the plan guard | | `region_group_boot_witness_test.py` | 58 | `region-group-boot-witness.py` | | `region_group_ssm_boot_test.py` | 3 | SSM boot | | `region_group_boot_umask_test.py` | 6 | Boot umask | - `region_group_witness_fake.py` is a simulation-only fake of AWS. - **How CI runs them:** `internal/provision/region_group_guards_test.go`: - `TestRegionGroupPythonGuards` (:203) runs `check_region_group_plan_test` and `region_group_contract_test`. - `TestRegionGroupHeldPythonGuards` (:218) runs `region_group_held_test` and `region_group_document_test`, with TMPDIR set to the test's temp directory. - `groupGuardBinary` (:119) fails if python3 is missing in CI and skips locally. - The gate is `.amadan/ci.d/10-gate`, which runs `go test ./...`. - **Not run by any Go test:** the roll, probe, fault, ssm_boot, boot_umask and boot_witness tests. I found no wrapper for them. - **"3000 seeds"** is the Go simulation, not Python. `internal/sim/regionha/handover_test.go` (`runHandoverScenario` :2093) runs through `TestRegionHA`, which reads `RHASIM_SEEDS` and defaults to 200 (`sim_test.go:15-42`). The 3000-seed run is a manual step per implementation revision (`docs/superpowers/plans/2026-11-03-region-ha-p1b3b-duties.md:377`). `handover_witness_test.go:329` covers 200 seeds. Two gaps for the port: Go has no elbv2 SDK module and no SSM StartSession or session-manager-plugin code. And because `rootaws` refuses profiles when run as root, there is no existing pattern for an operator verb that uses a local AWS profile.</result> <usage><subagent_tokens>102766</subagent_tokens><tool_uses>45</tool_uses><duration_ms>260110</duration_ms></usage> </task-notification>
<task-notification> <task-id>a92686154b70b9668</task-id> <tool-use-id>toolu_01Y3SZAgYdGG3CwraTnnGxnR</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/669506ff-23ec-45f1-9035-1d29593f2c37/tasks/a92686154b70b9668.output</output-file> <status>completed</status> <summary>Agent "Placeholder check" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**1. Conditional PutObject.** Yes, but it isn't in `internal/objstore` or `internal/s3compat`. It lives in `internal/release`: - **Interface:** `release.Store` (`internal/release/store.go:50-63`), with methods `Get(ctx,key) (body, etag, err)`, `Put(ctx,key,body,ifMatch) (newEtag, err)`, `List`, `ListDirs` and `Delete`. - **How `Put` decides:** an empty `ifMatch` sends `If-None-Match: *` (create-only); a non-empty one sends `If-Match: <etag>`. Losing either race returns `ErrCASConflict` (doc at `store.go:33-49`, implementation in `S3Store.putRaw` at `store.go:992-1003`, and again at `store.go:1041-1045`). - **Extras:** `S3Store.GetIfChanged` (`store.go:1153`) and `release.DeleteIfMatch` (`internal/release/conditional_delete.go:29`). - **`internal/objstore`** is the control plane for per-app stores. Its `Put`/`PutIn` (`objstore.go:326,333`) sit on top of `release.Store`. - **`internal/s3compat`** only adds client quirks. Its one quirk, `unquotedIfMatch` (`s3compat.go:113-175`), strips the quotes from `If-Match` on PutObject because Ceph RGW (Hetzner) rejects the quoted form. **Testing:** `internal/s3fake/s3fake.go:1-10` is an in-process S3 server that handles conditional requests and is held to the same contract (`TestS3StoreFakeContract`). Against real MinIO: - `TestS3StoreMinioContract` (`internal/release/s3_minio_test.go:21`) runs the `release.Store` contract. - `TestDeliveredContractMinio` (`internal/objstore/contract_test.go:46`) covers Put/Get/List/Delete with the credentials an app receives, plus a check that a second, ungranted bucket is denied. I didn't confirm it tests conditional puts. Both are skipped unless `CARLOS_MINIO_TEST=1`. CI's `.amadan/ci.d/30-minio-contract` step starts MinIO and sets it. **2. The two AWS packages.** - **`internal/awsregiongroup`:** "completes only a box's original launch action" (`complete.go:1`). `Completer` wraps one Auto Scaling call, `CompleteLifecycleAction` with result `CONTINUE` (`complete.go:17-41`). It uses `aws-sdk-go-v2/service/autoscaling` v1.74.0 (`go.mod:10`). There is no other Auto Scaling wrapper (no describe or update-group calls). - **`internal/rootaws`:** "keeps root's AWS clients away from executable shared profiles" (`config.go:1`). It loads config and static credentials, scrubs the environment, and opens the credentials file per OS (`open_linux.go`, `open_darwin.go`). It has no Auto Scaling code. **3. golang.org/x/sys and PTY code.** `golang.org/x/sys v0.49.0` is in go.mod (`go.mod:31`). PTY code exists only in tests: - `interactive_term_linux_test.go:14-21` and `internal/instanceexec/tty_linux_test.go:27-41` both open `/dev/ptmx` and unlock it with `unix.TIOCSPTLCK`. - `internal/execsandbox/oci.go:93` only sets the `ptmxmode` mount option on devpts. There is no production PTY helper, no `Openpt` call, and no darwin PTY code. **4. How a verb is registered in `internal/clireg`.** The CLI is a tree of `clireg.Node` values (`internal/clireg/clireg.go:42-80`). Each node has a `Name`, optional `Aliases`, `Children`, `Run` (leaf handler), `Transparent`, `Fallback`, `Audience` and `Golden`. Top-level commands are listed in `commandRoot()` (`commands.go:30`), which includes `systemCommand()` at `commands.go:153`. The `system` subcommands are listed in `systemCommand()` (`system.go:50-98`, children from line 57). A leaf is usually built with `raw(name, audience, func([]string))` (`commands.go:37`); `audience` is `clireg.Operator` or `clireg.BoxLocal`. `noHint` (`commands.go:43`) wraps a node to suppress the update hint. `clireg.Dispatch` (`dispatch.go:20`) walks the tree, and `Validate` checks it is well formed. The existing `system group` branch is `systemGroupCommand()` (`system_roles.go:123`), so a new group verb would go under it.</result> <usage><subagent_tokens>38679</subagent_tokens><tool_uses>7</tool_uses><duration_ms>50118</duration_ms></usage> </task-notification>