oficina / equipo Public

plans: Task 17 live plan, revision 5 (Fable's shape)

Paul's 2026-11-28 ruling: hard stops for safety only, FINDINGs for the
rest; reads never stop; every Lambda call through livectl (R40); the
managed operator policy from the start; pre-approved fallbacks for the
base image, the contract, 9.B echoes and 10.2's connector delete;
section 12 re-run (13 left); PIN_SHA waits for Astra's livectl review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev f4a7b0f8025fcab5ae7cdd68404ad5808aa0e2bc parent aa4d182
1 file changed, +681 −604
  • docs/superpowers/plans/2026-11-23-hosted-1a-task17-live-plan.md +681 −604
diff --git a/docs/superpowers/plans/2026-11-23-hosted-1a-task17-live-plan.md b/docs/superpowers/plans/2026-11-23-hosted-1a-task17-live-plan.md
index 170d4931..fff3c665 100644
--- a/docs/superpowers/plans/2026-11-23-hosted-1a-task17-live-plan.md
+++ b/docs/superpowers/plans/2026-11-23-hosted-1a-task17-live-plan.md
@@ -1,83 +1,71 @@
# Hosted runners 1a, Task 17: live check plan (for Paul's approval)
-**Revision:** 4 (2026-11-25), after attempt 2 stopped safely at 2.2 (the connector was refused;
-nothing billable created; its network and role are being torn down separately). Revision 3
-(`30d21b0a`) was the approved one. **Status:** draft for re-approval of the changes below, which
-follow Paul's ruling of 2026-11-25; no AWS command or SDK call of any kind was made while writing it.
-
-## Changes since the approved revision (`30d21b0a`)
-
-1. **Longer IAM propagation waits (2.1, 3.3).** Both blocks now wait 60 s after the role and its
- policy exist, instead of 15 s. IAM is eventually consistent, and the role is used by another
- service (Lambda) assuming it; attempt 2's connector call came about 21 s after the role was
- created and was refused.
-2. **Connector retry and fallback (2.2).** On the exact refusal attempt 2 saw
- (`InvalidParameterValueException`, "invalid ConnectorOperatorRole permissions"), the block
- checks no connector exists, waits 120 s and retries once with the same narrow policy. If that
- is refused too, it switches the role, for this throwaway dev run only, to the AWS-managed
- `AWSLambdaNetworkConnectorOperatorPolicy` plus an inline `ec2:DeleteNetworkInterface`
- permission limited to this account, region, Lambda-connector-managed interfaces and this
- run's subnet, waits
- 120 s and tries once more. A third refusal is a safe stop. The policy that worked is recorded
- (`CONN_OPERATOR_POLICY`). 2.2 now runs as a long block (bound 15 minutes).
-3. **Image create retry (3.7).** The build role is used straight after 3.3, so a synchronous
- refusal from `create-microvm-image` that identifies the build role or Lambda assuming it gets
- the same treatment: check no image exists, wait 120 s, retry once; a second refusal is a safe
- stop. Denials of the caller and all other errors are not retried.
-4. **Skip-never-created rule (section 10 and S.3).** Each teardown and safe-stop step acts only on
- resources with a confirmed creation record and journals a `SKIP` for resources never attempted
- or shown absent, so teardown runs as written after an early stop. An unresolved creation (an
- intent with neither a confirmation nor a `NOTCREATED` record) is never skipped: it aborts the
- step, and 10.9 refuses to remove the scratch, until S.2 reconciles it. 10.8 no longer requires
- an image.
-5. **10.4 removes whatever the operator role holds:** the narrow inline policy, the fallback's
- inline policy and the managed attachment, each accepted as already absent (`NoSuchEntity`).
-6. **The IAM exception in the summary** now names the fallback's attach, put and detach calls.
-7. **10.8 matches records by their full value.** A deletion is now recorded under the same value
- as its creation: roles by ARN (they were recorded by name), and the fallback's inline policy and
- managed attachment when present. 10.8 compares whole values, so a multi-ID record matches.
-8. **10.3 records the VPC defaults as deleted,** including the default group's rules, after a
- filtered `describe` confirms each is gone with the VPC.
-
-## What Paul approves with one GO
-
-- **Where.** Account `640012953448` (profile `kass`), region `eu-west-1`. Every AWS call runs
- through one guard that clears ambient credentials and endpoint overrides, pins the profile and
- region, and checks the STS account before the block does anything else. Nothing touches
- `149757027610`; any ARN naming it aborts.
-- **Global endpoint, one named exception (R37).** No Cost Explorer or other billing call (R33):
- spend is estimated from rates and the recorded lifetimes of what the run created, and Paul reads
- the bill himself. IAM is global, with no regional endpoint, so the IAM calls for the two roles
- (the image build role and the connector's network-interface role: create, attach inline policy,
- read back, tag during S.2 reconciliation if needed, on 2.2's fallback replace the inline policy
- and attach the AWS-managed connector operator policy, detach and delete) are the one exception
- to eu-west-1-only. They run behind the same `kass`
- account check as every other call, and Paul's one approval covers them.
-- **Tags (R34).** Every taggable resource gets `purpose=equipo-hosted-dev` and `run=<RUN>` (a
- random run ID chosen in 0.2): the VPC, its default security group (and that group's two default
- rules), its main route table and its default network ACL, the subnet, the route table, the
- security group, both IAM roles, the connector, the S3 bucket and the S3 object, the log group,
- the SNS topic and the MicroVM image. Two kinds of resource cannot carry our tags:
- - **MicroVMs** have no tag field. Each is recorded by ID in the run's VM ledger (from the launch
- reply, from test and controller logs, and from every image-scoped List of this run's image,
- R32), and teardown proves each one ended.
- - **The connector's network interfaces** are created and deleted by Lambda. They are recorded by
- ID when the connector is ACTIVE and verified gone after the connector is deleted.
-- **Code.** The exact revision `PIN_SHA` = `a7f505a0` (the pre-flight's final commit, R35). Before anything is
- built, 0.1 checks that HEAD contains it, that it contains R32 (`f95575c6`), and that nothing
- outside `docs/` differs from it, committed or not.
-- **The reaper is scoped to this run's image (R32).** The controller's List, and so its orphan
- scan, reads only VMs of the configured image ARN, which is this run's image, named with the run
- ID. It cannot see or stop other people's MicroVMs in `kass`. Account-wide VM counts in 0.4 are
- observations only.
-- **Spend.** Expected about $0.55. Worst case about $9.90: every approved branch at its bound at
- once, VMs that fail to stop included (each ends at its AWS maximum duration). Retained storage
- after an abort is separate and not in that figure: the image costs about $0.50 to $5.40 a month
- until teardown (S.4). **$10 is the approval ceiling**, not a guaranteed maximum. The operational
- stop rule: the run's own estimate (section 11.2), computed at the end of every section from each
- VM's provider start time, reaching $5, or any VM live outside its step, means the safe stop.
-- **Deviations.** Any changed command, any extra AWS call, any result outside a step's expected
- branches: safe stop, then ask.
+**Revision:** 5 (2026-11-28), in the shape Fable's review proposed and Paul accepted, after attempt
+3 stopped safely at 2.4 and was torn down (`52d73c2c`). Revision 4 (`c5f9bc36`) was the approved
+one. **Status:** draft for approval. No AWS command or SDK call of any kind was made while writing
+it.
+
+## What Paul approves
+
+One run in account `640012953448` (profile `kass`), region `eu-west-1`, every call behind the
+account and region guard; IAM is the one global-endpoint exception (R37) and there is no billing
+call (R33). Every Lambda MicroVMs and Lambda core call goes through `livectl`, the pinned Go SDK
+tool (R40), which refuses any other account, region or name outside the run; EC2, IAM, S3, SNS,
+CloudWatch Logs and STS stay on the CLI. Every taggable resource carries `purpose=equipo-hosted-dev`
+and `run=<RUN>`; MicroVMs (no tag field) and the connector's Lambda-managed interfaces are recorded
+by ID and proven gone (R34). The code is the exact revision `PIN_SHA` (R35), and the controller's
+reaper sees only this run's image (R32). The run stops hard only for safety: the wrong account or
+region, spend (the run's own estimate reaching $5; $10 is the approval ceiling), a MicroVM alive
+outside its step, or anything not in the ledger. It also stops when a step that later steps need
+cannot complete (a resource that cannot be created or deleted). Everything else that differs from
+expectation becomes a `FINDING:` line in the journal and the run goes on where it safely can; the
+report lists every FINDING. Reads of the run's own resources never stop it. Paul also pre-approves
+these fallbacks: the operator role uses the AWS-managed connector policy plus a subnet-scoped
+delete from the start; 3.6 to 3.8 step down one base image version once; the contract runs to
+completion; 9.B records echoes instead of asserting them; and 10.2 drops the delete policy's
+managed-operator condition once if the connector cannot be deleted. Expected spend is about $0.55,
+worst case about $9.90, retained image storage after an early stop about $0.50 to $5.40 a month.
+Any other change to a command, or any AWS call not written here, comes back to Paul first.
+
+## Changes since revision 4 (`c5f9bc36`)
+
+1. **Two kinds of stop.** Hard stops are for safety only: account or region, spend, a VM alive
+ outside its step, anything not in the ledger; plus a step later steps need that cannot complete.
+ Everything else is a `FINDING:` journal line (`finding`, `fact_eq`, `fact_lv`) and the run goes
+ on. The report lists every FINDING.
+2. **Reads of the run's own resources never stop the run;** a read that errors is a FINDING.
+3. **livectl for every Lambda MicroVMs and Lambda core call (R40).** It is built in 0.2 and called
+ through `lv`. jq now reads the SDK's Go field names, with unions under `.Value`. Client tokens
+ start with the run prefix, as livectl's guard requires. A livectl guard refusal is a hard stop.
+ 0.4's account-wide MicroVM count is dropped: livectl lists by image, and R32 makes the count
+ irrelevant.
+4. **Code pin.** `PIN_SHA` is the livectl commit after Astra's review (P1). 0.1 checks it contains
+ `a36861a0` (livectl) and `f95575c6` (R32), and runs livectl's offline tests.
+5. **Operator role.** 2.1 creates it with `AWSLambdaNetworkConnectorOperatorPolicy` plus the inline
+ subnet-scoped delete, then waits 120 s for propagation (the wait before attempt 3's accepted
+ call). 2.2 creates the connector once. The narrow policy and its retries are gone.
+6. **Connector version (2.4).** The version-1 qualified ARN is read back through livectl (`Version`
+ 1, `VersionArn`, ACTIVE, this subnet and group). The unqualified read's `LatestVersionArn` and the
+ version list are recorded as facts. No interfaces while ACTIVE is normal (attempt 3).
+7. **Base image (3.6 to 3.8).** livectl reads `Status` and `SupportedCpuConfigurations`. 3.6 picks
+ the newest `AVAILABLE` x86_64 version and the next one down. If the create (3.7) or the build
+ (3.8) fails, it steps down once.
+8. **Contract (6.1).** It runs to completion, and every failed subtest becomes a FINDING with its
+ own messages. All its VMs are still settled.
+9. **Facts (9).** 9.B records the egress, role, idle-policy and ingress echoes as facts. The Date
+ header comes from livectl's `ResultMetadata.ServerTime`. Unexpected codes in 9.A to 9.G are
+ FINDINGs; any VM an experiment made is still ended before the next one.
+10. **Controller sections.** A 5.6 audit that does not pass is a FINDING, and 7 and 8 are then
+ skipped. Driver and evidence failures in 7 and 8 are FINDINGs. An orphan alive past P+15:00
+ stays a hard stop.
+11. **Teardown.** 10.1 deletes the image (all versions) through livectl. 10.2 deletes the
+ connector through livectl. On `DELETE_FAILED`, or interfaces left at the bound, 10.2 drops the
+ delete policy's `ec2:ManagedResourceOperator` condition (keeping the subnet condition) and
+ retries once; a second failure is a hard stop. Image versions are no longer separate teardown
+ objects.
+12. **Section 12 re-run.** Settled: U3, U10, U12, U13 and the create half of U2. U11, U14, U17 and
+ U19 are now FINDINGs. New: U21 (a qualified egress ARN on RunMicrovm) and U22 (livectl's
+ interface after Astra).
## Order of execution
@@ -89,7 +77,7 @@ follow Paul's ruling of 2026-11-25; no AWS command or SDK call of any kind was m
| 4 | 3. Image | 30 to 45 min |
| 5 | 4. SNS topic | 2 min |
| 6 | 5. Keys, config, builds, and the audit-only controller run | 15 min |
-| 7 | 9.A to 9.F, facts by CLI (no controller running) | 40 min |
+| 7 | 9.A to 9.F, facts through livectl (no controller running) | 40 min |
| 8 | 6. Live contract | 30 min |
| 9 | 7. Controller sequence and crash check | 45 min |
| 10 | 8. Orphan | 25 min |
@@ -97,7 +85,7 @@ follow Paul's ruling of 2026-11-25; no AWS command or SDK call of any kind was m
| 12 | 10. Teardown and verification | 45 to 75 min |
The SDK-side network audit (5.6) runs before any VM is launched, so the connector's `VersionArn`
-and Elastic IP setting, which the installed CLI cannot show, are checked before the first launch.
+and Elastic IP setting are checked by the controller's own code before the first launch.
## Rules for every block
@@ -108,10 +96,26 @@ and Elastic IP setting, which the installed CLI cannot show, are checked before
- **One block, one Bash tool call, run by bash.** Every block begins with
`set -euo pipefail; . "${TMPDIR:?}/equipo-t17/env.sh"` and, if it calls AWS, `guard`. The
environment file (0.2) defines every helper the blocks use; nothing is pasted by hand.
-- **Failure is loud.** A failed command ends the block. Calls that are expected to fail run under
- `try` and pass only through an explicit branch (`expect_err`, `code_in`) that names the accepted
- error codes; anything else aborts. Every poll fails when its bound runs out.
-- **Abort means the safe stop (section S), then ask Paul.** Nothing else runs after an abort.
+- **Two kinds of stop (Paul, 2026-11-28).** `die` is kept for the hard stops: the wrong account or
+ region (`guard`, livectl's own guard), spend (11.2's $5 rule; $10 is the approval ceiling), a
+ MicroVM alive outside its step (`settle_all`, `vm_end`, the orphan bound), anything not in the
+ ledger (collision checks, unknown resources, unresolved creations), and a step later steps need
+ that cannot complete (a create or delete that fails, the connector's qualified ARN, the image).
+ Everything else that differs from expectation is a `finding`: a `FINDING` line in the journal,
+ printed with `FINDING:`, and the block goes on. The report lists every FINDING.
+- **Reads never stop the run.** A read of the run's own resources that errors or answers
+ differently is a FINDING (`fact_eq`, `fact_json`, `fact_lv`), except a read that a hard stop
+ depends on (the VM scans that prove VMs ended, and deletion checks).
+- **Failure is loud.** A failed command that is not handled ends the block. Calls that are expected
+ to fail run under `try` or `lv` and pass only through an explicit branch that names the accepted
+ error codes. Every poll fails when its bound runs out.
+- **livectl (R40).** Every Lambda MicroVMs and Lambda core call goes through `lv`, which runs
+ `$T17/bin/livectl -run <RUN>` (built in 0.2 from the pinned code). Its replies are the SDK's
+ output structs with Go field names (`State`, `VersionArn`, `MicrovmId`) and unions under
+ `.Value`; its errors are one JSON line whose `code` `lv` puts in `ECODE` and whose `aws_message`
+ it puts in `LV_MSG`. A livectl guard refusal (exit 4) or usage error (exit 3) is a hard stop.
+ Client tokens start with the run prefix, as livectl requires.
+- **A hard stop means the safe stop (section S), then ask Paul.** Nothing else runs after it.
- **Ledger.** Before each create call the block writes an `INTENT` line (kind, run-specific name or
token); after the call it records the confirmed ID with `rec` (checked writes, ARN checks). Every
MicroVM ID that appears anywhere is added to the VM ledger with `vmrec`. A deletion is recorded
@@ -125,7 +129,7 @@ and Elastic IP setting, which the installed CLI cannot show, are checked before
`INTENT` with neither): never skipped; the block aborts, so teardown cannot complete, S.3 cannot
report "never created", and 10.9 cannot remove the scratch until S.2 reconciles it.
- **Long blocks, one mechanism.** These blocks can run past the Bash tool's 10-minute limit for one
- call: 2.2, 2.3, 3.8, 3.9, 6.1, 7.2, 7.3, 7.4, 8.2, 9.A, 9.C, 10.1 and 10.2 (bounds below). Each is
+ call: 2.1, 2.3, 3.8, 3.9, 6.1, 7.2, 7.3, 7.4, 8.2, 9.A, 9.C, 10.1 and 10.2 (bounds below). Each is
written to a script file and run detached from a sandbox-off shell, and its exit status is read
from a status file. Every one of them starts with the sandbox-off header, so it runs the same way
detached. The agent never uses another background mechanism.
@@ -161,12 +165,12 @@ and Elastic IP setting, which the installed CLI cannot show, are checked before
```
An exit status other than 0, or the bound passing, is an abort (safe stop). Bounds in minutes:
- 2.2: 15; 2.3: 20; 3.8: 25; 3.9: 25; 6.1: 75; 7.2: 40; 7.3: 15; 7.4: 25; 8.2: 25; 9.A: 15; 9.C: 15;
- 10.1: 30; 10.2: 60.
+ 2.1: 10; 2.3: 20; 3.8: 50; 3.9: 25; 6.1: 75; 7.2: 40; 7.3: 15; 7.4: 25; 8.2: 25; 9.A: 15; 9.C: 15;
+ 10.1: 30; 10.2: 100.
- **The controller, with the sandbox off (R37).** A sandboxed Bash call kills its child processes
when it returns, so every block that starts, checks or stops the controller runs with the agent's
sandbox OFF: 5.6, 6.1, 7.1, 7.2, 7.3, 7.4, 8.1, 8.2, 9.A, 9.G, 10.1, 10.9, S.1 and S.3, plus
- the other long blocks (2.3, 3.8, 3.9, 9.C, 10.2), which run detached. Outside
+ the other long blocks (2.1, 2.3, 3.8, 3.9, 9.C, 10.2), which run detached. Outside
the sandbox `$TMPDIR` is different, so those blocks set `T17` explicitly to the path 0.2 printed;
their first line reads `set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"`, and that
path is the only text the agent fills in. `start_ctl` starts the controller with `setsid nohup`,
@@ -180,7 +184,8 @@ and Elastic IP setting, which the installed CLI cannot show, are checked before
their defaults; every Go command runs with `CGO_ENABLED=0`. No sudo.
- **Records.** After each section, append its results to
`docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md` under `## Task 17 live run`, and commit that
- file locally at the end (subject under 80 characters). Never push.
+ file locally at the end (subject under 80 characters). Never push. The report lists every
+ `FINDING` line (10.9 prints them all).
---
@@ -188,18 +193,18 @@ and Elastic IP setting, which the installed CLI cannot show, are checked before
### 0.1 Code pin and local tools (no AWS call)
-`PIN_SHA` is `a7f505a0` (`a7f505a0d69a2459062c83cb46baf7882e261c5f`), the pre-flight's final commit
-(cleanup fixes and evidence logging in `41178b00` and `3103334e`; R36 in `6b7f6ee1`: the adapter
-refuses MicroVM IDs that are not 1 to 128 characters of `[A-Za-z0-9-]`, failing closed), relayed by
-the coordinator.
+`PIN_SHA` is the commit holding livectl after Astra's review (placeholder P1, relayed by the
+coordinator). It must contain livectl's first commit `a36861a0`, R32 (`f95575c6`) and the earlier
+pre-flight work. The block also runs livectl's offline tests.
```sh
set -euo pipefail
-PIN_SHA='a7f505a0d69a2459062c83cb46baf7882e261c5f'
+PIN_SHA='<FROM COORDINATOR AFTER ASTRA: livectl commit SHA>'
case "$PIN_SHA" in *'<'*|'') echo "ABORT: PIN_SHA is not filled in"; exit 1;; esac
cd /home/paulca/amadan.net/oficina/equipo-hosted-1a
git rev-parse --verify "$PIN_SHA^{commit}"
git merge-base --is-ancestor f95575c6 "$PIN_SHA" || { echo "ABORT: $PIN_SHA does not contain R32 (f95575c6)"; exit 1; }
+git merge-base --is-ancestor a36861a0 "$PIN_SHA" || { echo "ABORT: $PIN_SHA does not contain livectl (a36861a0)"; exit 1; }
git merge-base --is-ancestor "$PIN_SHA" HEAD || { echo "ABORT: HEAD does not contain $PIN_SHA"; exit 1; }
d=$(git diff "$PIN_SHA" HEAD -- . ':!docs'); [ -z "$d" ] || { echo "ABORT: code differs from $PIN_SHA outside docs/"; exit 1; }
s=$(git status --porcelain --untracked-files=all -- . ':!docs'); [ -z "$s" ] || { echo "ABORT: uncommitted changes outside docs/:"; echo "$s"; exit 1; }
@@ -207,10 +212,11 @@ git log --oneline -1
aws --version
go version
for t in jq openssl sha256sum curl ss python3 setsid nohup; do command -v "$t" >/dev/null || { echo "ABORT: missing $t"; exit 1; }; done
+CGO_ENABLED=0 go test -tags hostedlive ./internal/isolatedjob/awsjob/livectl -count=1
echo "code pin ok: $PIN_SHA"
```
-- Expected: `code pin ok`; `aws-cli/2.36.x`; `go1.26.x`.
+- Expected: livectl's offline tests pass; `code pin ok`; `aws-cli/2.36.x`; `go1.26.x`.
- Abort if: any check fails.
### 0.1a Remove attempt 1's scratch, only if it created nothing (no AWS call)
@@ -264,6 +270,7 @@ export AWS_PROFILE=kass AWS_REGION=eu-west-1 AWS_DEFAULT_REGION=eu-west-1 AWS_PA
export CGO_ENABLED=0
if [ -z "${T17:-}" ]; then T17="$TMPDIR/equipo-t17"; fi
export T17 REPO=/home/paulca/amadan.net/oficina/equipo-hosted-1a
+export LIVECTL="$T17/bin/livectl"
export ACCOUNT=640012953448 TAGV=equipo-hosted-dev
export LEDGER="$T17/ledger.env" JOURNAL="$T17/journal.tsv" VMS="$T17/vms.tsv"
export NO_INGRESS=arn:aws:lambda:eu-west-1:aws:network-connector:aws-network-connector:NO_INGRESS
@@ -287,7 +294,8 @@ arn_ok() {
jw() { local t="$*"; t=${t//$'\r'/}; t=${t//$'\n'/ | }; t=${t//$'\t'/ }
printf '%s\t%s\n' "$(date -u +%FT%T.%3NZ)" "$t" >> "$JOURNAL" || { echo "ABORT: journal write failed" >&2; exit 1; }; }
# _kind VAR: sets K_I and K_N, the journal patterns for VAR's INTENT and NOTCREATED records ("" when
-# VAR has no creation of its own, such as the VPC defaults, which exist only with the VPC).
+# VAR has no creation of its own: the VPC defaults exist only with the VPC, and image versions only
+# with the image, which livectl deletes whole).
_kind() { case "$1" in
VPC) K_I='^INTENT vpc( |$)'; K_N='^NOTCREATED vpc( |$)';;
SUBNET) K_I='^INTENT subnet( |$)'; K_N='^NOTCREATED subnet( |$)';;
@@ -300,8 +308,7 @@ _kind() { case "$1" in
BUCKET_CREATED) K_I='^INTENT s3-bucket( |$)'; K_N='^NOTCREATED s3-bucket( |$)';;
LOG_GROUP_CREATED) K_I='^INTENT log-group( |$)'; K_N='^NOTCREATED log-group( |$)';;
ARTIFACT) K_I='^INTENT s3-object( |$)'; K_N='^NOTCREATED s3-object( |$)';;
- IMAGE_ARN|VER_SMALL) K_I='^INTENT microvm-image( |$)'; K_N='^NOTCREATED (microvm-image|image attempt)( |$)';;
- VER_LARGE) K_I='^INTENT microvm-image-version( |$)'; K_N='^NOTCREATED image version 4096( |$)';;
+ IMAGE_ARN) K_I='^INTENT microvm-image( |$)'; K_N='^NOTCREATED (microvm-image|image attempt)( |$)';;
TOPIC_ARN) K_I='^INTENT sns-topic( |$)'; K_N='^NOTCREATED sns-topic( |$)';;
*) K_I=''; K_N='';;
esac; }
@@ -324,7 +331,7 @@ have() {
esac
}
# no_unresolved: abort if any resource is still unresolved.
-no_unresolved() { local v; for v in VPC SUBNET RTB RTB_ASSOC SG OPERATOR_ROLE_ARN BUILD_ROLE_ARN CONN_ARN BUCKET_CREATED LOG_GROUP_CREATED ARTIFACT IMAGE_ARN VER_LARGE TOPIC_ARN; do
+no_unresolved() { local v; for v in VPC SUBNET RTB RTB_ASSOC SG OPERATOR_ROLE_ARN BUILD_ROLE_ARN CONN_ARN BUCKET_CREATED LOG_GROUP_CREATED ARTIFACT IMAGE_ARN TOPIC_ARN; do
creation_state "$v"; [ "$CST" != unresolved ] || die "$v is unresolved; reconcile it (S.2) before finishing"; done; }
# gone0 WHAT CMD...: a list read that must succeed and count 0 (no error code is guessed).
gone0() { local w=$1; shift; get _g "$@"; [ "$_g" = 0 ] || die "$w is still listed ($_g)"; }
@@ -353,6 +360,39 @@ try() {
must() { [ "$RC" = 0 ] || die "call failed (rc $RC, ${ECODE:-no code}): $ERR"; }
# get VAR CMD...: run a read; abort unless it succeeded; only then store its output in VAR.
get() { local __v=$1; shift; try "$@"; must; printf -v "$__v" '%s' "$OUT"; }
+# lv ARGS...: one livectl call (every Lambda MicroVMs and Lambda core call, R40). Sets OUT, ERR, RC,
+# ECODE (the smithy error code), LV_KIND (api, transport, usage, guard, timeout, failed_state, other)
+# and LV_MSG (the service's own text). A guard refusal (4) or usage error (3) is a hard stop.
+lv() {
+ [ -x "$LIVECTL" ] || die "livectl is not built at $LIVECTL"
+ need RUN
+ try "$LIVECTL" -run "$RUN" "$@"
+ ECODE=""; LV_KIND=""; LV_MSG=""
+ if [ "$RC" != 0 ]; then
+ local e; e=$(tail -n 1 <<<"$ERR")
+ ECODE=$(jq -r '.code // empty' <<<"$e" 2>/dev/null || true)
+ LV_KIND=$(jq -r '.error // empty' <<<"$e" 2>/dev/null || true)
+ LV_MSG=$(jq -r '.aws_message // empty' <<<"$e" 2>/dev/null || true)
+ fi
+ [ "$RC" != 4 ] || die "livectl guard refusal (account, region, run prefix or -run): $ERR"
+ [ "$RC" != 3 ] || die "livectl usage error (a plan defect): $ERR"
+ return 0
+}
+# finding TEXT: a FINDING line in the journal; the run goes on (Paul's rule 1).
+finding() { jw "FINDING $*"; echo "FINDING: $*"; }
+# fact_eq WHAT WANT CMD...: a read of the run's own resource; a failed read or another value is a FINDING.
+fact_eq() { local w=$1 want=$2; shift 2; try "$@"
+ if [ "$RC" != 0 ]; then finding "$w: read failed (${ECODE:-rc$RC})"; elif [ "$OUT" = "$want" ]; then echo "ok: $w"; else finding "$w: got [$OUT], want [$want]"; fi; }
+# fact_json WHAT WANT CMD...: as fact_eq, comparing compacted JSON.
+fact_json() { local w=$1 want=$2 got; shift 2; try "$@"
+ if [ "$RC" != 0 ]; then finding "$w: read failed (${ECODE:-rc$RC})"; return 0; fi
+ got=$(jq -c . <<<"$OUT" 2>/dev/null) || { finding "$w: reply is not JSON"; return 0; }
+ if [ "$got" = "$(jq -c . <<<"$want")" ]; then echo "ok: $w"; else finding "$w: got $got, want $want"; fi; }
+# fact_lv WHAT WANT JQ ARGS...: a livectl read; jq -r JQ of the reply must equal WANT, else a FINDING.
+fact_lv() { local w=$1 want=$2 q=$3 got; shift 3; lv "$@"
+ if [ "$RC" != 0 ]; then finding "$w: read failed (${ECODE:-rc$RC})"; return 0; fi
+ got=$(jq -r "$q" <<<"$OUT" 2>/dev/null) || { finding "$w: reply unreadable"; return 0; }
+ if [ "$got" = "$want" ]; then echo "ok: $w"; else finding "$w: got [$got], want [$want]"; fi; }
# code_in CODE...: after try, 0 if the call failed with one of CODE.
code_in() { local c; [ "$RC" != 0 ] || return 1; for c; do [ "$ECODE" = "$c" ] && return 0; done; return 1; }
# expect_err CODE...: after try, the call must have failed with one of CODE (an expected-failure branch).
@@ -392,10 +432,10 @@ vm_ids() { [ -f "$VMS" ] || die "no VM ledger"; VIDS=$(cut -f1 "$VMS" | sort -u)
# scan: one image-scoped List, every page, every state; records every ID; writes last_scan.tsv.
scan() {
need IMAGE_ARN
- try aws lambda-microvms list-microvms --image-identifier "$IMAGE_ARN" --output json; must
- printf '%s' "$OUT" | jq -e '.items | type == "array"' >/dev/null || die "list reply has no items array"
- printf '%s' "$OUT" | jq -e --arg a "$IMAGE_ARN" 'all(.items[]; .imageArn == $a)' >/dev/null || die "list returned a VM of another image"
- printf '%s' "$OUT" | jq -r '.items[] | [.microvmId, .state, .startedAt] | @tsv' > "$T17/last_scan.tsv"
+ lv vm list -image "$IMAGE_ARN"; must
+ printf '%s' "$OUT" | jq -e '.Items | type == "array"' >/dev/null || die "list reply has no Items array"
+ printf '%s' "$OUT" | jq -e --arg a "$IMAGE_ARN" 'all(.Items[]; .ImageArn == $a)' >/dev/null || die "list returned a VM of another image"
+ printf '%s' "$OUT" | jq -r '.Items[] | [.MicrovmId, .State, .StartedAt] | @tsv' > "$T17/last_scan.tsv"
local id st started
while IFS=$'\t' read -r id st started; do [ -n "$id" ] && vmrec "$id" scan "$started"; done < "$T17/last_scan.tsv"
LIVE=$(awk -F'\t' '$2 != "TERMINATED" {print $1}' "$T17/last_scan.tsv") || die "scan output unreadable"
@@ -404,16 +444,16 @@ scan() {
# After scan, LIVE holds the IDs of this image's VMs that are not TERMINATED.
# vm_get ID: sets VST to the state, NOTFOUND, or ERROR:<code>.
vm_get() {
- try aws lambda-microvms get-microvm --microvm-identifier "$1" --query state --output text
- if [ "$RC" = 0 ]; then VST=$OUT; elif [ "$ECODE" = ResourceNotFoundException ]; then VST=NOTFOUND; else VST="ERROR:${ECODE:-rc$RC}"; fi
+ lv vm get -id "$1"
+ if [ "$RC" = 0 ]; then VST=$(jq -r '.State // empty' <<<"$OUT"); [ -n "$VST" ] || VST="ERROR:no-state"; elif [ "$ECODE" = ResourceNotFoundException ]; then VST=NOTFOUND; else VST="ERROR:${ECODE:-rc$RC}"; fi
}
_vm_check() { vm_get "$1"; echo "$(date -u +%T) $1 $VST"; [ "$VST" = "$2" ] && return 0; case " $3 ThrottlingException " in *" ${VST#ERROR:} "*) return 1;; esac; return 2; }
# vm_wait ID TARGET SECONDS ALLOWED...: wait for TARGET; a state outside ALLOWED is fatal.
vm_wait() { local id=$1 t=$2 s=$3; shift 3; poll "$s" 5 "VM $id to $t" _vm_check "$id" "$t" "$*"; }
# vm_end ID: terminate and confirm: TERMINATED, or not found twice at least 60 s apart.
vm_end() {
- try aws lambda-microvms terminate-microvm --microvm-identifier "$1"
- [ "$RC" = 0 ] || [ "$ECODE" = ResourceNotFoundException ] || die "terminate $1: ${ECODE:-rc$RC} $ERR"
+ lv vm terminate -id "$1"
+ [ "$RC" = 0 ] || [ "$ECODE" = ResourceNotFoundException ] || die "terminate $1: ${ECODE:-rc$RC} ${LV_MSG:-$ERR}"
local nf=0 end=$(( $(date +%s) + 600 ))
while :; do
vm_get "$1"; echo "$(date -u +%T) $1 $VST"
@@ -446,20 +486,20 @@ settle_all() {
done
die "VMs still live after three settle rounds"
}
-# launch LABEL TOKEN MAXSECONDS PAYLOADFILE: one run-microvm (Small, NO_INGRESS, the connector); records any VM it returns.
+# launch LABEL TOKEN MAXSECONDS PAYLOADFILE: one livectl vm run (Small, NO_INGRESS, the connector);
+# records any VM it returns. TOKEN must start with the run prefix.
launch() {
need IMAGE_ARN VER_SMALL CONN_QARN; [ -f "$4" ] || die "no payload file $4"
intent vm "$1" "token=$2" "max=$3"
local t0; t0=$(date -u +%FT%T.%3NZ)
- try aws lambda-microvms run-microvm --image-identifier "$IMAGE_ARN" --image-version "$VER_SMALL" --client-token "$2" \
- --ingress-network-connectors "$NO_INGRESS" --egress-network-connectors "$CONN_QARN" \
- --maximum-duration-in-seconds "$3" --run-hook-payload "file://$4" --output json
+ lv vm run -image "$IMAGE_ARN" -version "$VER_SMALL" -connector "$CONN_QARN" -max-seconds "$3" \
+ -client-token "$2" -payload-file "$4"
printf '%s\n' "$OUT" > "$T17/out/launch-$1.json"; printf '%s\n' "$ERR" > "$T17/out/launch-$1.err"
- L_RC=$RC; L_CODE=$ECODE; L_ID=""
+ L_RC=$RC; L_CODE=$ECODE; L_MSG=$LV_MSG; L_ID=""
if [ "$RC" = 0 ]; then
- L_ID=$(printf '%s' "$OUT" | jq -r '.microvmId // empty')
- [ -n "$L_ID" ] || die "launch $1 succeeded with no microvmId"
- local st; st=$(printf '%s' "$OUT" | jq -r '.startedAt // empty')
+ L_ID=$(printf '%s' "$OUT" | jq -r '.MicrovmId // empty')
+ [ -n "$L_ID" ] || die "launch $1 succeeded with no MicrovmId"
+ local st; st=$(printf '%s' "$OUT" | jq -r '.StartedAt // empty')
vmrec "$L_ID" "$1" "${st:-phase:$t0}"
fi
echo "launch $1: rc=$L_RC code=${L_CODE:-none} id=${L_ID:-none}"
@@ -554,7 +594,7 @@ ENVEOF
RUN=$(date -u +%m%d)-$(openssl rand -hex 3)
NAME=equipo-hosted-dev-t17-$RUN
cat > "$TMPDIR/equipo-t17/run.env" <<RUNEOF
-export PIN_SHA='a7f505a0d69a2459062c83cb46baf7882e261c5f'
+export PIN_SHA='<FROM COORDINATOR AFTER ASTRA: livectl commit SHA>'
export RUN=$RUN NAME=$NAME
export OPERATOR_ROLE=$NAME-conn-op BUILD_ROLE=$NAME-build CONN_NAME=$NAME-egress IMAGE_NAME=$NAME
export BUCKET=$NAME-640012953448 LOG_GROUP=/aws/lambda-microvms/$NAME TOPIC_NAME=$NAME-alerts SG_NAME=$NAME-vm
@@ -564,10 +604,13 @@ touch "$TMPDIR/equipo-t17/ledger.env" "$TMPDIR/equipo-t17/journal.tsv" "$TMPDIR/
. "$TMPDIR/equipo-t17/env.sh"
case "$PIN_SHA" in *'<'*) die "PIN_SHA in run.env is not filled in";; esac
jw "RUN $RUN start pin=$PIN_SHA"
-echo "T17=$T17 RUN=$RUN NAME=$NAME"
+(cd "$REPO" && CGO_ENABLED=0 go build -tags hostedlive -o "$LIVECTL" ./internal/isolatedjob/awsjob/livectl)
+[ -x "$LIVECTL" ] || die "livectl did not build"
+echo "T17=$T17 RUN=$RUN NAME=$NAME LIVECTL=$LIVECTL"
```
-- The `PIN_SHA` line in `run.env` carries the same value as 0.1.
+- The `PIN_SHA` line in `run.env` carries the same value as 0.1. livectl is built from the
+ checked-out code, which 0.1 proved is the pinned revision.
- Expected: one line with the scratch path, the run ID and the base name. Record the `T17=` path:
sandboxed blocks find it through `$TMPDIR`, and the sandbox-off blocks (R37) set it from this line.
The environment file refuses to load if the directory is not there.
@@ -578,9 +621,11 @@ echo "T17=$T17 RUN=$RUN NAME=$NAME"
```sh
set -euo pipefail; . "${TMPDIR:?}/equipo-t17/env.sh"; guard
aws sts get-caller-identity --query '[Account,Arn]' --output text
+lv caller; must
+[ "$(jq -r '"\(.Account) \(.Region)"' <<<"$OUT")" = "640012953448 eu-west-1" ] || die "livectl sees $(jq -c . <<<"$OUT")"
```
-- Expected: `640012953448` and an ARN in that account.
+- Expected: `640012953448` and an ARN in that account, from the CLI and from livectl.
- Abort if: anything else. Nothing else runs.
### 0.4 Observations and collision checks
@@ -591,21 +636,21 @@ the exact name and must get the "does not exist" answer.
```sh
set -euo pipefail; . "${TMPDIR:?}/equipo-t17/env.sh"; guard
need RUN NAME OPERATOR_ROLE BUILD_ROLE CONN_NAME IMAGE_NAME BUCKET LOG_GROUP TOPIC_NAME
-try aws lambda-microvms list-microvms --query "length(items[?state!='TERMINATED'])" --output json; must
-echo "observation: live MicroVMs in the account and region (any image, not ours to touch): $OUT"
try aws resourcegroupstaggingapi get-resources --tag-filters Key=purpose,Values=$TAGV --query 'ResourceTagMappingList[].ResourceARN' --output text; must
echo "observation: resources already tagged purpose=$TAGV (not ours, never touched): [$OUT]"
try aws ec2 describe-vpcs --filters Name=tag:run,Values=$RUN --query 'Vpcs[].VpcId' --output text; must; [ -z "$OUT" ] || die "a VPC already has run=$RUN"
for r in "$OPERATOR_ROLE" "$BUILD_ROLE"; do try aws iam get-role --role-name "$r"; expect_err NoSuchEntity; done
-try aws lambda-core get-network-connector --identifier "$CONN_NAME"; expect_err ResourceNotFoundException
-get _v aws lambda-microvms list-microvm-images --query "length(items[?name=='$IMAGE_NAME'])" --output json; [ "$_v" = 0 ] || die "image name $IMAGE_NAME exists"
+lv connector get -id "$CONN_NAME"; { [ "$RC" != 0 ] && [ "$ECODE" = ResourceNotFoundException ]; } || die "connector name $CONN_NAME: rc $RC ${ECODE:-} (it exists, or the check could not run)"
+lv image list -name "$IMAGE_NAME"; must
+[ "$(jq --arg n "$IMAGE_NAME" '[.Items[] | select(.Name == $n)] | length' <<<"$OUT")" = 0 ] || die "image name $IMAGE_NAME exists"
get _v aws s3api list-buckets --prefix "$BUCKET" --query "length(Buckets[?Name=='$BUCKET'])" --output json; [ "$_v" = 0 ] || die "bucket $BUCKET exists in this account"
try aws logs describe-log-groups --log-group-name-prefix "$LOG_GROUP" --query 'logGroups[].logGroupName' --output text; must; [ -z "$OUT" ] || die "log group exists: $OUT"
get _v aws sns list-topics --query "length(Topics[?TopicArn=='arn:aws:sns:eu-west-1:$ACCOUNT:$TOPIC_NAME'])" --output json; [ "$_v" = 0 ] || die "topic $TOPIC_NAME exists"
jw "COLLISION-CHECKS clean"; echo "collision checks clean"
```
-- Expected: two observation lines; `collision checks clean`.
+- Expected: one observation line; `collision checks clean`. A collision is "anything not in the
+ ledger", a hard stop.
- Abort if: any name exists, or a lookup fails. The image, bucket and topic checks list and match
the exact name (the CLI reads every page), so they need no error code. A bucket name held by
another account is not listed here; `create-bucket` in 3.1 then fails before anything is created,
@@ -628,8 +673,8 @@ rec VPC "$(jq -r .Vpc.VpcId "$T17/out/1.1-vpc.json")"
aws ec2 wait vpc-available --vpc-ids "$VPC"
aws ec2 modify-vpc-attribute --vpc-id "$VPC" --enable-dns-hostnames '{"Value":false}'
aws ec2 modify-vpc-attribute --vpc-id "$VPC" --enable-dns-support '{"Value":false}'
-get v aws ec2 describe-vpc-attribute --vpc-id "$VPC" --attribute enableDnsSupport --query EnableDnsSupport.Value --output text; [ "$v" = False ] || die "enableDnsSupport is $v"
-get v aws ec2 describe-vpc-attribute --vpc-id "$VPC" --attribute enableDnsHostnames --query EnableDnsHostnames.Value --output text; [ "$v" = False ] || die "enableDnsHostnames is $v"
+fact_eq "VPC enableDnsSupport" False aws ec2 describe-vpc-attribute --vpc-id "$VPC" --attribute enableDnsSupport --query EnableDnsSupport.Value --output text
+fact_eq "VPC enableDnsHostnames" False aws ec2 describe-vpc-attribute --vpc-id "$VPC" --attribute enableDnsHostnames --query EnableDnsHostnames.Value --output text
get DEF aws ec2 describe-security-groups --filters Name=vpc-id,Values="$VPC" Name=group-name,Values=default --query 'SecurityGroups[].GroupId' --output text
[ "$(wc -w <<<"$DEF")" = 1 ] || die "default groups: [$DEF]"; rec DEF_SG "$DEF"
get DEF aws ec2 describe-route-tables --filters Name=vpc-id,Values="$VPC" Name=association.main,Values=true --query 'RouteTables[].RouteTableId' --output text
@@ -640,7 +685,7 @@ get DEF aws ec2 describe-security-group-rules --filters Name=group-id,Values="$D
[ -n "$DEF" ] || die "the default group has no rules to tag"; rec DEF_SG_RULES "$DEF"
aws ec2 create-tags --resources "$DEF_SG" "$MAIN_RTB" "$DEF_ACL" $DEF_SG_RULES --tags $TAGS_EC2
get n aws ec2 describe-tags --filters Name=resource-id,Values="$VPC,$DEF_SG,$MAIN_RTB,$DEF_ACL,$(tr '\t ' ',,' <<<"$DEF_SG_RULES")" Name=key,Values=purpose --query 'length(Tags)' --output text
-[ "$n" = $(( 4 + $(wc -w <<<"$DEF_SG_RULES") )) ] || die "purpose tag on $n resources"
+[ "$n" = $(( 4 + $(wc -w <<<"$DEF_SG_RULES") )) ] || finding "purpose tag read back on $n resources"
echo "VPC $VPC: DNS support and hostnames off; defaults tagged: $DEF_SG $MAIN_RTB $DEF_ACL $DEF_SG_RULES"
```
@@ -659,7 +704,7 @@ printf '%s\n' "$OUT" > "$T17/out/1.2-subnet.json"
rec SUBNET "$(jq -r .Subnet.SubnetId "$T17/out/1.2-subnet.json")"
aws ec2 wait subnet-available --subnet-ids "$SUBNET"
get got aws ec2 describe-subnets --subnet-ids "$SUBNET" --query 'Subnets[0].[VpcId,CidrBlock,AvailabilityZone,MapPublicIpOnLaunch]' --output text
-[ "$got" = "$VPC 10.177.1.0/24 eu-west-1a False" ] || die "subnet is [$got]"
+[ "$got" = "$VPC 10.177.1.0/24 eu-west-1a False" ] || finding "subnet is [$got]"
echo "subnet $SUBNET ok"
```
@@ -679,9 +724,9 @@ intent route-table-association "" "$RTB/$SUBNET"
try aws ec2 associate-route-table --route-table-id "$RTB" --subnet-id "$SUBNET" --query AssociationId --output text; must
rec RTB_ASSOC "$OUT"
get got aws ec2 describe-route-tables --route-table-ids "$RTB" --query 'RouteTables[0].Routes[].[DestinationCidrBlock,GatewayId,State]' --output text
-[ "$got" = "10.177.0.0/16 local active" ] || die "routes are [$got]"
+[ "$got" = "10.177.0.0/16 local active" ] || finding "routes are [$got]"
get got aws ec2 describe-route-tables --filters Name=association.subnet-id,Values="$SUBNET" --query 'RouteTables[].RouteTableId' --output text
-[ "$got" = "$RTB" ] || die "the subnet uses [$got]"
+[ "$got" = "$RTB" ] || finding "the subnet uses [$got]"
echo "route table $RTB: local route only, associated"
```
@@ -696,14 +741,13 @@ try aws ec2 create-security-group --group-name "$SG_NAME" --description "Task 17
printf '%s\n' "$OUT" > "$T17/out/1.4-sg.json"
rec SG "$(jq -r .GroupId "$T17/out/1.4-sg.json")"
aws ec2 describe-security-group-rules --filters Name=group-id,Values="$SG" --output json > "$T17/out/1.4-rules.json"
-jq -e '[.SecurityGroupRules[] | select(.IsEgress)] | length == 1' "$T17/out/1.4-rules.json" >/dev/null || die "not exactly one default egress rule"
-jq -e '.SecurityGroupRules[] | select(.IsEgress) | .IpProtocol == "-1" and .CidrIpv4 == "0.0.0.0/0"' "$T17/out/1.4-rules.json" >/dev/null || die "the default egress rule is not all traffic to 0.0.0.0/0"
-jq -e '[.SecurityGroupRules[] | select(.IsEgress | not)] | length == 0' "$T17/out/1.4-rules.json" >/dev/null || die "the new group has inbound rules"
-rule=$(jq -r '.SecurityGroupRules[] | select(.IsEgress) | .SecurityGroupRuleId' "$T17/out/1.4-rules.json")
-get _v aws ec2 revoke-security-group-egress --group-id "$SG" --security-group-rule-ids "$rule" --query Return --output text; [ "$_v" = True ] || die "revoke failed"
+jq -e '[.SecurityGroupRules[] | select(.IsEgress)] | length == 1' "$T17/out/1.4-rules.json" >/dev/null || finding "not exactly one default egress rule: $(jq -c . "$T17/out/1.4-rules.json")"
+jq -e '[.SecurityGroupRules[] | select(.IsEgress | not)] | length == 0' "$T17/out/1.4-rules.json" >/dev/null || finding "the new group has inbound rules"
+rules=$(jq -r '.SecurityGroupRules[] | select(.IsEgress) | .SecurityGroupRuleId' "$T17/out/1.4-rules.json")
+[ -z "$rules" ] || [ "$(aws ec2 revoke-security-group-egress --group-id "$SG" --security-group-rule-ids $rules --query Return --output text)" = True ] || die "revoking the default egress rules failed"
get got aws ec2 describe-security-groups --group-ids "$SG" --query 'SecurityGroups[0].[length(IpPermissions),length(IpPermissionsEgress)]' --output text
-[ "$got" = "0 0" ] || die "rules left: [$got]"
-get _v aws ec2 describe-security-group-rules --filters Name=group-id,Values="$SG" --query 'length(SecurityGroupRules)' --output text; [ "$_v" = 0 ] || die "rule list not empty"
+[ "$got" = "0 0" ] || finding "rules left: [$got]"
+fact_eq "VM group rule count" 0 aws ec2 describe-security-group-rules --filters Name=group-id,Values="$SG" --query 'length(SecurityGroupRules)' --output text
echo "security group $SG: no rules"
```
@@ -711,179 +755,139 @@ echo "security group $SG: no rules"
## 2. Connector
-### 2.1 The connector's network-interface role (least privilege)
+### 2.1 The connector's network-interface role
The trust policy is the one AWS documents for the connector operator role (Lambda Web Functions
networking guide: `lambda.amazonaws.com`, `sts:AssumeRole`), plus `sts:TagSession`, which only lets
-Lambda tag the session it assumes; it does not widen who can assume the role. The permissions
-replace the broad managed policy `AWSLambdaNetworkConnectorOperatorPolicy` (which allows creating
-interfaces in any subnet with any group) with statements scoped to this subnet and this group. The
-pinned SDK says the role also needs `ec2:DeleteNetworkInterface` and describe calls; delete is
-limited to interfaces in this subnet. EC2 `Describe*` calls have no resource-level scoping, so they
-are a separate statement on `*`, read-only. After the role and its policy exist, the block waits
-60 s: IAM changes are eventually consistent, and Lambda must be able to assume the new role from
-its own service (attempt 2's connector call came 21 s after creation and was refused). If 2.2 is
-still refused, it retries and then falls back as Paul ruled on 2026-11-25 (see 2.2).
+Lambda tag the session it assumes. Attempts 2 and 3 showed a narrow, scoped policy is refused when
+the connector is created, even 3.3 minutes later, while the AWS-managed
+`AWSLambdaNetworkConnectorOperatorPolicy` plus an inline delete was accepted. So, for this
+throwaway dev run (Paul, 2026-11-25 and 2026-11-28), the role gets the managed policy from the
+start, plus an inline `ec2:DeleteNetworkInterface` (the managed policy has none). The delete is
+scoped as narrowly as EC2 allows before the interfaces exist: this account and region,
+network-interface resources only, only interfaces whose `ec2:ManagedResourceOperator` is the
+Lambda connector service, and only interfaces in this run's subnet. The block then waits 120 s
+for IAM propagation, the wait that preceded attempt 3's accepted call.
```sh
-set -euo pipefail; . "${TMPDIR:?}/equipo-t17/env.sh"; guard
-need SUBNET SG OPERATOR_ROLE RUN
-cat > "$T17/iam/lambda-trust.json" <<'EOF'
+set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
+need SUBNET OPERATOR_ROLE RUN
+cat > "$T17/iam/lambda-trust.json" <<'TEOF'
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"lambda.amazonaws.com"},"Action":["sts:AssumeRole","sts:TagSession"]}]}
-EOF
+TEOF
A=arn:aws:ec2:eu-west-1:640012953448
-cat > "$T17/iam/operator.json" <<EOF
+cat > "$T17/iam/operator-delete.json" <<TEOF
{"Version":"2012-10-17","Statement":[
- {"Sid":"CreateEniInThisSubnetWithThisGroup","Effect":"Allow","Action":"ec2:CreateNetworkInterface",
- "Resource":["$A:subnet/$SUBNET","$A:security-group/$SG"]},
- {"Sid":"CreateConnectorEniInThisSubnet","Effect":"Allow","Action":"ec2:CreateNetworkInterface",
- "Resource":"$A:network-interface/*",
- "Condition":{"ArnEquals":{"ec2:Subnet":"$A:subnet/$SUBNET"},
- "ForAllValues:StringEquals":{"aws:TagKeys":["aws:lambda:networkConnectorName","aws:lambda:networkConnectorId"]}}},
- {"Sid":"TagConnectorEniOnCreate","Effect":"Allow","Action":"ec2:CreateTags","Resource":"$A:network-interface/*",
- "Condition":{"StringEquals":{"ec2:CreateAction":"CreateNetworkInterface","ec2:ManagedResourceOperator":"network-connectors.lambda.amazonaws.com"}}},
- {"Sid":"DeleteEniInThisSubnet","Effect":"Allow","Action":"ec2:DeleteNetworkInterface","Resource":"$A:network-interface/*",
- "Condition":{"ArnEquals":{"ec2:Subnet":"$A:subnet/$SUBNET"}}},
- {"Sid":"DescribeHasNoResourceScope","Effect":"Allow","Action":["ec2:DescribeNetworkInterfaces","ec2:DescribeSubnets","ec2:DescribeSecurityGroups","ec2:DescribeVpcs"],"Resource":"*"}]}
-EOF
-jq -e . "$T17/iam/operator.json" >/dev/null
+ {"Sid":"DeleteLambdaConnectorEniOnly","Effect":"Allow","Action":"ec2:DeleteNetworkInterface","Resource":"$A:network-interface/*",
+ "Condition":{"StringEquals":{"ec2:ManagedResourceOperator":"network-connectors.lambda.amazonaws.com"},
+ "ArnEquals":{"ec2:Subnet":"$A:subnet/$SUBNET"}}}]}
+TEOF
+jq -e . "$T17/iam/operator-delete.json" >/dev/null
intent iam-role "$OPERATOR_ROLE"
try aws iam create-role --role-name "$OPERATOR_ROLE" --description "Task 17 connector network interfaces, run $RUN" \
--assume-role-policy-document "file://$T17/iam/lambda-trust.json" \
--tags Key=purpose,Value=$TAGV Key=run,Value=$RUN --query Role.Arn --output text; must
arn_ok "$OUT"; rec OPERATOR_ROLE_ARN "$OUT"
-aws iam put-role-policy --role-name "$OPERATOR_ROLE" --policy-name t17-connector-eni --policy-document "file://$T17/iam/operator.json"
+aws iam attach-role-policy --role-name "$OPERATOR_ROLE" --policy-arn arn:aws:iam::aws:policy/AWSLambdaNetworkConnectorOperatorPolicy
+rec OPERATOR_MANAGED_POLICY arn:aws:iam::aws:policy/AWSLambdaNetworkConnectorOperatorPolicy
+aws iam put-role-policy --role-name "$OPERATOR_ROLE" --policy-name t17-connector-eni-delete --policy-document "file://$T17/iam/operator-delete.json"
+rec OPERATOR_INLINE_POLICY t17-connector-eni-delete
aws iam wait role-exists --role-name "$OPERATOR_ROLE"
-get _v aws iam list-role-policies --role-name "$OPERATOR_ROLE" --query 'PolicyNames' --output text; [ "$_v" = t17-connector-eni ] || die "inline policy missing"
-get _v aws iam list-attached-role-policies --role-name "$OPERATOR_ROLE" --query 'length(AttachedPolicies)' --output text; [ "$_v" = 0 ] || die "managed policy attached"
-sleep 60
+fact_json "operator inline policies" '["t17-connector-eni-delete"]' aws iam list-role-policies --role-name "$OPERATOR_ROLE" --query 'PolicyNames' --output json
+fact_json "operator managed policies" '["AWSLambdaNetworkConnectorOperatorPolicy"]' aws iam list-attached-role-policies --role-name "$OPERATOR_ROLE" --query 'AttachedPolicies[].PolicyName' --output json
+echo "waiting 120 s for IAM propagation before Lambda assumes the operator role"; sleep 120
echo "operator role $OPERATOR_ROLE_ARN ready"
```
-- Abort if: any call fails. A synchronous refusal of the connector create follows 2.2's retry and
- fallback. A connector that was created and later fails on the role's permissions (for example
- `FAILED` with `InsufficientRolePermissions` in 2.3) stays a safe stop; nothing else widens the
- policy.
-
-### 2.2 Create the VPC_EGRESS connector for MicroVMs (retry, then fallback)
-
-Attempt 2 saw `CreateNetworkConnector` refuse synchronously with `InvalidParameterValueException`,
-"Encountered unauthorized operation while calling EC2 due to invalid ConnectorOperatorRole
-permissions", about 21 s after the role was created; no connector was created. Paul ruled
-(2026-11-25), for this throwaway dev run only:
-
-1. Try with the narrow policy from 2.1.
-2. On that exact refusal: confirm no connector exists, wait 120 s for IAM propagation, retry once
- with the same narrow policy.
-3. If refused again: replace the role's inline policy with the AWS-managed
- `AWSLambdaNetworkConnectorOperatorPolicy` plus an inline `ec2:DeleteNetworkInterface`, wait
- 120 s, and try once more. The managed policy has no delete; the delete is scoped as narrowly as
- EC2 allows before the interfaces exist: this account and region, network-interface resources
- only, only interfaces whose `ec2:ManagedResourceOperator` is the Lambda connector service
- (the condition AWS's own networking guide uses to limit permissions to the connector's own
- interfaces), and only interfaces in this run's subnet (`ec2:Subnet`), so another connector's
- interfaces elsewhere in the account are out of reach.
-4. A third refusal is a safe stop. Any other error at any step is a safe stop.
-
-The policy that worked is recorded as a fact (`CONN_OPERATOR_POLICY`). This block can run about
-5 minutes, so it runs as a long block.
+- Abort if: a create, attach or put call fails (2.2 needs the role).
+- The two readbacks are facts: `fact_json` compares the compacted JSON, and a difference is a
+ FINDING.
+
+### 2.2 Create the VPC_EGRESS connector for MicroVMs (once)
```sh
-set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
-need SUBNET SG OPERATOR_ROLE OPERATOR_ROLE_ARN CONN_NAME RUN
-CFG="{\"VpcEgressConfiguration\":{\"SubnetIds\":[\"$SUBNET\"],\"SecurityGroupIds\":[\"$SG\"],\"NetworkProtocol\":\"IPv4\",\"AssociatedComputeResourceTypes\":[\"MicroVm\"]}}"
-REFUSAL='invalid ConnectorOperatorRole permissions'
-# create_conn N: one attempt with client token $CONN_NAME-N. CONN_RC=0 created; CONN_RC=1 the
-# role refusal, with no connector created; any other result aborts.
-create_conn() {
- intent connector "$CONN_NAME" "token=$CONN_NAME-$1"
- try aws lambda-core create-network-connector --name "$CONN_NAME" --configuration "$CFG" \
- --operator-role "$OPERATOR_ROLE_ARN" --tags purpose=$TAGV,run=$RUN --client-token "$CONN_NAME-$1" --output json
- if [ "$RC" = 0 ]; then CONN_RC=0; return 0; fi
- if [ "$ECODE" = InvalidParameterValueException ] && grep -qF "$REFUSAL" <<<"$ERR"; then
- jw "REFUSED connector attempt $1: $ERR"; echo "attempt $1 refused: operator role permissions"
- try aws lambda-core get-network-connector --identifier "$CONN_NAME"; expect_err ResourceNotFoundException
- jw "NOTCREATED connector attempt $1"; CONN_RC=1; return 0
+set -euo pipefail; . "${TMPDIR:?}/equipo-t17/env.sh"; guard
+need SUBNET SG OPERATOR_ROLE_ARN CONN_NAME RUN
+intent connector "$CONN_NAME" "token=$CONN_NAME-1"
+lv connector create -name "$CONN_NAME" -role "$OPERATOR_ROLE_ARN" -subnet "$SUBNET" -sg "$SG" \
+ -client-token "$CONN_NAME-1" -tag purpose=$TAGV -tag run=$RUN
+if [ "$RC" != 0 ]; then
+ if [ "$ECODE" = InvalidParameterValueException ] && grep -qF 'invalid ConnectorOperatorRole permissions' <<<"$LV_MSG"; then
+ msg=$LV_MSG
+ lv connector get -id "$CONN_NAME"
+ if [ "$RC" != 0 ] && [ "$ECODE" = ResourceNotFoundException ]; then jw "NOTCREATED connector attempt 1"; fi
+ die "the connector was refused with the managed operator policy ($msg); 2.3 onwards needs it"
fi
- die "create-network-connector attempt $1: ${ECODE:-rc$RC} $ERR"
-}
-create_conn 1; policy="narrow, first try"
-if [ "$CONN_RC" = 1 ]; then
- echo "waiting 120 s for IAM propagation, then one retry with the same narrow policy"; sleep 120
- create_conn 2; policy="narrow, after a 120 s wait"
-fi
-if [ "$CONN_RC" = 1 ]; then
- A=arn:aws:ec2:eu-west-1:640012953448
- cat > "$T17/iam/operator-delete.json" <<EOF
-{"Version":"2012-10-17","Statement":[
- {"Sid":"DeleteLambdaConnectorEniOnly","Effect":"Allow","Action":"ec2:DeleteNetworkInterface","Resource":"$A:network-interface/*",
- "Condition":{"StringEquals":{"ec2:ManagedResourceOperator":"network-connectors.lambda.amazonaws.com"},
- "ArnEquals":{"ec2:Subnet":"$A:subnet/$SUBNET"}}}]}
-EOF
- jq -e . "$T17/iam/operator-delete.json" >/dev/null
- jw "FALLBACK operator role: AWSLambdaNetworkConnectorOperatorPolicy plus inline delete (Paul, 2026-11-25)"
- aws iam delete-role-policy --role-name "$OPERATOR_ROLE" --policy-name t17-connector-eni
- aws iam attach-role-policy --role-name "$OPERATOR_ROLE" --policy-arn arn:aws:iam::aws:policy/AWSLambdaNetworkConnectorOperatorPolicy
- rec OPERATOR_MANAGED_POLICY arn:aws:iam::aws:policy/AWSLambdaNetworkConnectorOperatorPolicy
- aws iam put-role-policy --role-name "$OPERATOR_ROLE" --policy-name t17-connector-eni-delete --policy-document "file://$T17/iam/operator-delete.json"
- rec OPERATOR_INLINE_POLICY t17-connector-eni-delete
- get _v aws iam list-role-policies --role-name "$OPERATOR_ROLE" --query 'PolicyNames' --output json
- [ "$(jq -r 'join(" ")' <<<"$_v")" = t17-connector-eni-delete ] || die "operator inline policies are [$_v]"
- get _v aws iam list-attached-role-policies --role-name "$OPERATOR_ROLE" --query 'AttachedPolicies[].PolicyName' --output json
- [ "$(jq -r 'join(" ")' <<<"$_v")" = AWSLambdaNetworkConnectorOperatorPolicy ] || die "operator managed policies are [$_v]"
- echo "waiting 120 s for IAM propagation, then the last try"; sleep 120
- create_conn 3; policy="managed AWSLambdaNetworkConnectorOperatorPolicy plus inline delete"
- [ "$CONN_RC" = 0 ] || die "the connector was refused a third time, with the managed policy: safe stop"
+ die "connector create: rc $RC ${ECODE:-} ${LV_MSG:-$ERR} (uncertain: S.2 reconciles it)"
fi
-rec CONN_OPERATOR_POLICY "$policy"
printf '%s\n' "$OUT" > "$T17/out/2.2-connector.json"
arn_ok "$(jq -r .Arn "$T17/out/2.2-connector.json")"
rec CONN_ARN "$(jq -r .Arn "$T17/out/2.2-connector.json")"; rec CONN_ID "$(jq -r .Id "$T17/out/2.2-connector.json")"
[ "$CONN_ARN" = "arn:aws:lambda:eu-west-1:$ACCOUNT:network-connector:$CONN_ID" ] || die "connector ARN has an unexpected form: $CONN_ARN"
-jq '{Arn,Id,State}' "$T17/out/2.2-connector.json"
-echo "connector created with: $policy"
+rec CONN_OPERATOR_POLICY "managed AWSLambdaNetworkConnectorOperatorPolicy plus inline delete"
+jw "FACT connector create reply: $(jq -c '{State,Version,VersionArn,LatestVersion,LatestVersionArn}' "$T17/out/2.2-connector.json")"
+jq -c '{Arn,Id,State,Version,VersionArn}' "$T17/out/2.2-connector.json"
```
-- Expected: state `PENDING`, and the policy that worked. No `ElasticIpConfiguration` is sent, so the
- connector gets none; 5.6 confirms that through the SDK.
-- Abort if: any error other than the exact refusal, a refusal after the fallback, or any failed IAM
- call or readback in the fallback.
+- Expected: state `PENDING`. livectl sends no `ElasticIpConfiguration`, so the connector gets none;
+ 2.4 and 5.6 confirm it.
+- Abort if: the create fails. A refusal leaves no connector (attempt 2's evidence); anything else
+ is uncertain and S.2 reconciles it by name.
-### 2.3 Wait for ACTIVE (spike: about 4.5 min; bound 15 min)
+### 2.3 Wait for ACTIVE (spike and attempt 3: about 4.5 min; bound 15 min)
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
need CONN_ARN
-_conn() { try aws lambda-core get-network-connector --identifier "$CONN_ARN" --query '[State,StateReasonCode,StateReason]' --output text
- [ "$RC" = 0 ] || return 3; echo "$(date -u +%T) $OUT"; case "$OUT" in ACTIVE*) return 0;; PENDING*) return 1;; esac; return 2; }
-poll 900 15 "connector ACTIVE" _conn
+lv connector wait-active -id "$CONN_ARN" -timeout 15m -interval 15s
+printf '%s\n' "$OUT" > "$T17/out/2.3-active.json"
+jq -c '{State,StateReason,StateReasonCode}' "$T17/out/2.3-active.json" 2>/dev/null || true
+[ "$RC" = 0 ] || die "connector not ACTIVE (rc $RC, ${ECODE:-no code}); 2.4 onwards needs it"
jw "TIMING connector-active"
```
-- Abort if: `FAILED` (the line shows its reason code) or the bound runs out.
+- Abort if: a failed state (exit 6, the reply shows `StateReason`) or the bound runs out (exit 5).
-### 2.4 Version, qualified ARN, and the connector's network interfaces
+### 2.4 The version-1 qualified ARN, facts about versions, and the interfaces
+
+A new connector starts at version 1 (pinned SDK, `CreateNetworkConnector`). Attempt 3's discovery
+read `<arn>:1` and got `Version` 1, ACTIVE; the unqualified read carries only `LatestVersion` and
+`LatestVersionArn`. The launches and the 5.6 audit need the qualified ARN, so that read is a
+requirement; the rest are facts.
```sh
set -euo pipefail; . "${TMPDIR:?}/equipo-t17/env.sh"; guard
need CONN_ARN CONN_ID SUBNET SG VPC
-get v aws lambda-core get-network-connector --identifier "$CONN_ARN" --query Version --output text
-case "$v" in ''|*[!0-9]*) die "connector version is [$v]";; esac
-rec CONN_VERSION "$v"; rec CONN_QARN "$CONN_ARN:$CONN_VERSION"
-aws lambda-core get-network-connector --identifier "$CONN_QARN" --output json > "$T17/out/2.4-qualified.json"
-jq -e --arg s "$SUBNET" --arg g "$SG" '.State == "ACTIVE" and (.Configuration.VpcEgressConfiguration.SubnetIds == [$s]) and (.Configuration.VpcEgressConfiguration.SecurityGroupIds == [$g]) and (.Configuration.VpcEgressConfiguration.AssociatedComputeResourceTypes == ["MicroVm"])' "$T17/out/2.4-qualified.json" >/dev/null || die "qualified read differs: $(cat "$T17/out/2.4-qualified.json")"
-aws ec2 describe-network-interfaces --filters Name=vpc-id,Values="$VPC" --output json > "$T17/out/2.4-enis.json"
-jq -e --arg s "$SUBNET" 'all(.NetworkInterfaces[]; .SubnetId == $s)' "$T17/out/2.4-enis.json" >/dev/null || die "an interface outside the subnet"
-for e in $(jq -r '.NetworkInterfaces[].NetworkInterfaceId' "$T17/out/2.4-enis.json"); do jw "SERVICE-ENI $e"; done
-jq -r '.NetworkInterfaces[] | [.NetworkInterfaceId, .Status, .InterfaceType, (.TagSet // [] | map(.Key) | join(","))] | @tsv' "$T17/out/2.4-enis.json"
+lv connector get -id "$CONN_ARN:1"; must
+printf '%s\n' "$OUT" > "$T17/out/2.4-qualified.json"
+jq -e --arg q "$CONN_ARN:1" --arg s "$SUBNET" --arg g "$SG" '.Version == 1 and .VersionArn == $q and .State == "ACTIVE"
+ and .Configuration.Value.SubnetIds == [$s] and .Configuration.Value.SecurityGroupIds == [$g]
+ and .Configuration.Value.AssociatedComputeResourceTypes == ["MicroVm"]' "$T17/out/2.4-qualified.json" >/dev/null \
+ || die "the version-1 read does not show this run's ACTIVE connector: $(jq -c '{Version,VersionArn,State,Configuration}' "$T17/out/2.4-qualified.json")"
+rec CONN_VERSION 1; rec CONN_QARN "$CONN_ARN:1"
+fact_lv "connector Elastic IP configuration" "null" '.Configuration.Value.ElasticIpConfiguration' connector get -id "$CONN_QARN"
+lv connector get -id "$CONN_ARN"
+if [ "$RC" = 0 ]; then
+ jw "FACT unqualified read: $(jq -c '{Version,VersionArn,LatestVersion,LatestVersionArn,ServerTime:.ResultMetadata.ServerTime}' <<<"$OUT")"
+ [ "$(jq -r .LatestVersionArn <<<"$OUT")" = "$CONN_QARN" ] || finding "unqualified read: LatestVersionArn is $(jq -r .LatestVersionArn <<<"$OUT"), not $CONN_QARN"
+else finding "unqualified connector read failed: ${ECODE:-rc$RC}"; fi
+lv connector list-versions -id "$CONN_ARN"
+if [ "$RC" = 0 ]; then jw "FACT connector versions: $(jq -c '[.Items[] | {Version,VersionArn,State}]' <<<"$OUT")"
+else finding "connector version list failed: ${ECODE:-rc$RC}"; fi
+try aws ec2 describe-network-interfaces --filters Name=vpc-id,Values="$VPC" --output json
+if [ "$RC" = 0 ]; then
+ printf '%s\n' "$OUT" > "$T17/out/2.4-enis.json"
+ for e in $(jq -r '.NetworkInterfaces[].NetworkInterfaceId' "$T17/out/2.4-enis.json"); do jw "SERVICE-ENI $e"; done
+ jw "FACT interfaces in the VPC while ACTIVE: $(jq '.NetworkInterfaces | length' "$T17/out/2.4-enis.json")"
+ jq -e --arg s "$SUBNET" 'all(.NetworkInterfaces[]; .SubnetId == $s)' "$T17/out/2.4-enis.json" >/dev/null || finding "an interface outside the run's subnet"
+else finding "interface list failed: ${ECODE:-rc$RC}"; fi
echo "qualified connector ARN: $CONN_QARN"
```
-- Expected: a whole-number version; the qualified read is `ACTIVE` with only this subnet, this group
- and `MicroVm`. The installed CLI cannot show `VersionArn`, so the qualified ARN is built as
- `<Arn>:<Version>` (the form the networking guide prints) and proven by the SDK audit in 5.6.
- The interfaces are Lambda's: recorded as `SERVICE-ENI`, never deleted by the run, verified gone
- in 10.2.
+- Expected: the version-1 read is this run's ACTIVE connector, in this subnet with this group. No
+ Elastic IP configuration. Attempt 3 saw no interfaces while ACTIVE, which is recorded as a fact.
+ Interfaces Lambda creates later are recorded in 10.2 by the VPC-wide count.
+- Abort if: the version-1 read fails or shows another connector; everything after needs it.
---
@@ -906,7 +910,7 @@ try aws s3api create-bucket --bucket "$BUCKET" --create-bucket-configuration Loc
rec BUCKET_CREATED "$BUCKET"
aws s3api put-public-access-block --bucket "$BUCKET" --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
aws s3api put-bucket-tagging --bucket "$BUCKET" --tagging "TagSet=[{Key=purpose,Value=$TAGV},{Key=run,Value=$RUN}]"
-get _v aws s3api get-bucket-tagging --bucket "$BUCKET" --query "TagSet[?Key=='run'].Value" --output text; [ "$_v" = "$RUN" ] || die "bucket tags missing"
+fact_eq "bucket run tag" "$RUN" aws s3api get-bucket-tagging --bucket "$BUCKET" --query "TagSet[?Key=='run'].Value" --output text
echo "bucket $BUCKET ok"
```
@@ -919,7 +923,7 @@ intent log-group "$LOG_GROUP"
try aws logs create-log-group --log-group-name "$LOG_GROUP" --tags purpose=$TAGV,run=$RUN; must
rec LOG_GROUP_CREATED "$LOG_GROUP"
aws logs put-retention-policy --log-group-name "$LOG_GROUP" --retention-in-days 1
-get _v aws logs describe-log-groups --log-group-name-prefix "$LOG_GROUP" --query 'logGroups[].[logGroupName,retentionInDays]' --output text; [ "$_v" = "$LOG_GROUP 1" ] || die "log group readback differs"
+fact_eq "log group and retention" "$LOG_GROUP 1" aws logs describe-log-groups --log-group-name-prefix "$LOG_GROUP" --query 'logGroups[].[logGroupName,retentionInDays]' --output text
```
### 3.3 Build role (least privilege)
@@ -946,7 +950,7 @@ try aws iam create-role --role-name "$BUILD_ROLE" --description "Task 17 MicroVM
arn_ok "$OUT"; rec BUILD_ROLE_ARN "$OUT"
aws iam put-role-policy --role-name "$BUILD_ROLE" --policy-name t17-build --policy-document "file://$T17/iam/build.json"
aws iam wait role-exists --role-name "$BUILD_ROLE"
-get _v aws iam list-role-policies --role-name "$BUILD_ROLE" --query 'PolicyNames' --output text; [ "$_v" = t17-build ] || die "inline policy missing"
+fact_eq "build role inline policy" t17-build aws iam list-role-policies --role-name "$BUILD_ROLE" --query 'PolicyNames' --output text
echo "waiting 60 s for IAM propagation before Lambda assumes the build role"; sleep 60
```
@@ -1011,131 +1015,164 @@ rec ARTIFACT_B64 "$B64"
intent s3-object "s3://$BUCKET/t17/app.zip"
try aws s3api put-object --bucket "$BUCKET" --key t17/app.zip --body app.zip --checksum-algorithm SHA256 \
--checksum-sha256 "$B64" --tagging "purpose=$TAGV&run=$RUN" --query ChecksumSHA256 --output text; must
-[ "$OUT" = "$B64" ] || die "put-object checksum [$OUT]"
+[ "$OUT" = "$B64" ] || finding "put-object checksum [$OUT]"
rec ARTIFACT "s3://$BUCKET/t17/app.zip"
-get _v aws s3api head-object --bucket "$BUCKET" --key t17/app.zip --checksum-mode ENABLED --query ChecksumSHA256 --output text; [ "$_v" = "$B64" ] || die "S3 checksum differs"
-get _v aws s3api get-object-tagging --bucket "$BUCKET" --key t17/app.zip --query "TagSet[?Key=='run'].Value" --output text; [ "$_v" = "$RUN" ] || die "object tags missing"
+fact_eq "S3 object checksum" "$B64" aws s3api head-object --bucket "$BUCKET" --key t17/app.zip --checksum-mode ENABLED --query ChecksumSHA256 --output text
+fact_eq "S3 object run tag" "$RUN" aws s3api get-object-tagging --bucket "$BUCKET" --key t17/app.zip --query "TagSet[?Key=='run'].Value" --output text
echo "artifact $ARTIFACT digest $DIGEST"
```
### 3.6 Managed base image and version
+livectl reads each base version's `Status` and `SupportedCpuConfigurations` (the CLI dropped them).
+The block picks the newest `AVAILABLE` version that supports x86_64, and records the next one down
+for the pre-approved step down in 3.7 and 3.8.
+
```sh
set -euo pipefail; . "${TMPDIR:?}/equipo-t17/env.sh"; guard
-get base aws lambda-microvms list-managed-microvm-images --query "items[?imageArn=='arn:aws:lambda:eu-west-1:aws:microvm-image:al2023-1'].imageArn | [0]" --output text
-[ "$base" = arn:aws:lambda:eu-west-1:aws:microvm-image:al2023-1 ] || die "no al2023-1 base image: [$base]"
-rec BASE_ARN "$base"
-aws lambda-microvms list-managed-microvm-image-versions --image-identifier "$BASE_ARN" --query 'items[].[imageVersion,createdAt]' --output text
-get vs aws lambda-microvms list-managed-microvm-image-versions --image-identifier "$BASE_ARN" --query 'items[].imageVersion' --output text
-v=$(tr '\t' '\n' <<<"$vs" | sort -V | tail -n 1)
-case "${v%%.*}" in ''|*[!0-9]*) die "base version [$v]";; esac
-[ "${v%%.*}" -ge 3 ] || die "newest base version $v is below 3 (x86_64 needs 3 or later)"
-rec BASE_VER "$v"
+lv image base-versions; must
+printf '%s\n' "$OUT" > "$T17/out/3.6-base.json"
+jq -r '.Items[] | [.ImageVersion, .Status, ([.SupportedCpuConfigurations[]?.Architecture] | join(","))] | @tsv' "$T17/out/3.6-base.json"
+rec BASE_ARN "$(jq -r '.BaseImage' "$T17/out/3.6-base.json")"
+[ "$BASE_ARN" = arn:aws:lambda:eu-west-1:aws:microvm-image:al2023-1 ] || finding "base image ARN is $BASE_ARN"
+vs=$(jq -r '[.Items[] | select(.Status == "AVAILABLE" and any(.SupportedCpuConfigurations[]?; .Architecture == "X86_64"))] | .[0:2][] | .ImageVersion' "$T17/out/3.6-base.json")
+v1=$(sed -n 1p <<<"$vs"); v2=$(sed -n 2p <<<"$vs")
+[ -n "$v1" ] || die "no AVAILABLE base version supports x86_64; the image needs one"
+rec BASE_VER "$v1"
+if [ -n "$v2" ]; then rec BASE_VER_DOWN "$v2"; else finding "only one AVAILABLE x86_64 base version ($v1): no step down available"; fi
```
-- The installed CLI drops each version's `status` and `supportedCpuConfigurations` (U3), so this
- picks the newest listed version. If that version cannot build x86_64 or is not available, 3.7
- fails with a `ValidationException`: a stop (U4), with no other version tried.
+- Expected: the newest `AVAILABLE` x86_64 version, and one below it.
+- Abort if: the list fails, or no version is both `AVAILABLE` and x86_64.
### 3.7 Create the image: Small version
-The build role was created in 3.3, so a synchronous refusal about the build role gets the same
-propagation treatment as the connector: confirm no image exists, wait 120 s, retry once. It counts
-only if the code is `ValidationException`, `AccessDeniedException` or
-`InvalidParameterValueException`, the message names the build role (its name or ARN) or Lambda
-assuming it ("build role", "assume role"), and it is not a denial of the caller ("is not authorized
-to perform", such as a missing `iam:PassRole`). A second refusal, or any other error or denial, is a
-safe stop.
+Two pre-approved retries, each at most once:
+
+- **A refusal about the build role**, which was created in 3.3, gets the propagation treatment:
+ confirm no image exists, wait 120 s, retry with the same base version. It counts only if the
+ code is `ValidationException`, `AccessDeniedException` or `InvalidParameterValueException`; the
+ service's message names the build role (its name or ARN) or Lambda assuming it ("build role",
+ "assume role"); and it is not a denial of the caller ("is not authorized to perform").
+- **Any other refusal that leaves no image** steps down once to `BASE_VER_DOWN` (Paul,
+ 2026-11-28).
+
+Anything else, or a third refusal, is a stop: the image is needed.
```sh
set -euo pipefail; . "${TMPDIR:?}/equipo-t17/env.sh"; guard
-need IMAGE_NAME ARTIFACT BASE_ARN BASE_VER BUILD_ROLE_ARN LOG_GROUP RUN
-# create_image N: one attempt with client token $IMAGE_NAME-create-N. IMG_RC=0 created; IMG_RC=1 a
-# role refusal with no image created; anything else aborts.
+need IMAGE_NAME ARTIFACT BASE_ARN BASE_VER BUILD_ROLE_ARN BUILD_ROLE LOG_GROUP RUN
+# create_image BASEVERSION N: one attempt with client token $IMAGE_NAME-create-N. IMG_RC=0 created;
+# 1 a build-role refusal; 2 another refusal; both with no image left. Anything uncertain aborts.
create_image() {
- intent microvm-image "$IMAGE_NAME" "token=$IMAGE_NAME-create-$1"
- try aws lambda-microvms create-microvm-image --name "$IMAGE_NAME" --description "Task 17 minimal hook image, small, run $RUN" \
- --code-artifact "uri=$ARTIFACT" --base-image-arn "$BASE_ARN" --base-image-version "$BASE_VER" \
- --build-role-arn "$BUILD_ROLE_ARN" --cpu-configurations '[{"architecture":"X86_64"}]' \
- --resources '[{"minimumMemoryInMiB":2048}]' --additional-os-capabilities '["ALL"]' \
- --hooks "file://$T17/image/hooks.json" --logging "{\"cloudWatch\":{\"logGroup\":\"$LOG_GROUP\"}}" \
- --tags purpose=$TAGV,run=$RUN --client-token "$IMAGE_NAME-create-$1" --output json
+ intent microvm-image "$IMAGE_NAME" "token=$IMAGE_NAME-create-$2" "base=$1"
+ lv image create -name "$IMAGE_NAME" -description "Task 17 minimal hook image, small, run $RUN" \
+ -artifact "$ARTIFACT" -base "$BASE_ARN" -base-version "$1" -build-role "$BUILD_ROLE_ARN" \
+ -hooks "$T17/image/hooks.json" -log-group "$LOG_GROUP" -memory 2048 \
+ -client-token "$IMAGE_NAME-create-$2" -tag purpose=$TAGV -tag run=$RUN
if [ "$RC" = 0 ]; then IMG_RC=0; return 0; fi
- if code_in ValidationException AccessDeniedException InvalidParameterValueException \
- && { grep -qF -e "$BUILD_ROLE_ARN" -e "$BUILD_ROLE" <<<"$ERR" || grep -qiE 'build role|assume (the )?(build )?role' <<<"$ERR"; } \
- && ! grep -qi 'is not authorized to perform' <<<"$ERR"; then
- jw "REFUSED image attempt $1: $ERR"; echo "attempt $1 refused, naming a role"
- get _v aws lambda-microvms list-microvm-images --query "length(items[?name=='$IMAGE_NAME'])" --output json
- [ "$_v" = 0 ] || die "the refused create left an image named $IMAGE_NAME"
- jw "NOTCREATED image attempt $1"; IMG_RC=1; return 0
- fi
- die "create-microvm-image attempt $1: ${ECODE:-rc$RC} $ERR"
+ [ "$LV_KIND" = api ] || die "image create attempt $2: ${LV_KIND:-rc$RC} (no answer: S.2 reconciles it)"
+ IMG_CODE=$ECODE; IMG_MSG=$LV_MSG
+ jw "REFUSED image attempt $2 (base $1): ${IMG_CODE} ${IMG_MSG}"
+ lv image list -name "$IMAGE_NAME"; must
+ [ "$(jq --arg n "$IMAGE_NAME" '[.Items[] | select(.Name == $n)] | length' <<<"$OUT")" = 0 ] || die "a refused create left an image named $IMAGE_NAME"
+ jw "NOTCREATED image attempt $2"
+ case "$IMG_CODE" in ValidationException|AccessDeniedException|InvalidParameterValueException) role_code=yes;; *) role_code=no;; esac
+ if [ "$role_code" = yes ] \
+ && { grep -qF -e "$BUILD_ROLE_ARN" -e "$BUILD_ROLE" <<<"$IMG_MSG" || grep -qiE 'build role|assume (the )?(build )?role' <<<"$IMG_MSG"; } \
+ && ! grep -qi 'is not authorized to perform' <<<"$IMG_MSG"; then IMG_RC=1; else IMG_RC=2; fi
}
-create_image 1
-if [ "$IMG_RC" = 1 ]; then
- echo "waiting 120 s for IAM propagation, then one retry"; sleep 120
- create_image 2
- [ "$IMG_RC" = 0 ] || die "create-microvm-image was refused twice: safe stop"
-fi
+ver=$BASE_VER; n=1; waited=no; stepped=no
+while :; do
+ create_image "$ver" "$n"
+ [ "$IMG_RC" = 0 ] && break
+ if [ "$IMG_RC" = 1 ] && [ "$waited" = no ]; then waited=yes; echo "build-role refusal: waiting 120 s, then the same version"; sleep 120
+ elif [ "$IMG_RC" = 2 ] && [ "$stepped" = no ] && [ -n "${BASE_VER_DOWN:-}" ]; then
+ stepped=yes; finding "image create from base $ver refused (${IMG_CODE}: ${IMG_MSG}); stepping down to $BASE_VER_DOWN"; ver=$BASE_VER_DOWN
+ else die "image create refused (attempt $n, ${IMG_CODE}: ${IMG_MSG}); no pre-approved retry is left"; fi
+ n=$((n + 1))
+done
printf '%s\n' "$OUT" > "$T17/out/3.7-image.json"
-arn_ok "$(jq -r .imageArn "$T17/out/3.7-image.json")"
-rec IMAGE_ARN "$(jq -r .imageArn "$T17/out/3.7-image.json")"; rec VER_SMALL "$(jq -r .imageVersion "$T17/out/3.7-image.json")"
+arn_ok "$(jq -r .ImageArn "$T17/out/3.7-image.json")"
+rec IMAGE_ARN "$(jq -r .ImageArn "$T17/out/3.7-image.json")"; rec VER_SMALL "$(jq -r .ImageVersion "$T17/out/3.7-image.json")"
+rec BASE_VER_USED "$ver"; [ "$stepped" = no ] || rec BASE_STEPPED_DOWN yes
[ "$IMAGE_ARN" = "arn:aws:lambda:eu-west-1:$ACCOUNT:microvm-image:$IMAGE_NAME" ] || die "image ARN [$IMAGE_ARN]"
```
-- No `egressNetworkConnectors` is passed, so the build pulls its container base image over the
- default build path; running VMs get only the connector.
-- Abort if: an error; `X86_64` refused by the CLI or API (U3, U4, U5).
+- livectl always sends x86_64 and the `ALL` capability, and no egress connectors, so the build pulls
+ its container base image over the default build path; running VMs get only the connector.
+
+### 3.8 Wait for the Small version and check it (bound 50 min with the step down)
-### 3.8 Wait for the Small version and check it (bound 20 min)
+If the Small build fails and 3.7 has not stepped down, the block builds a new Small version from
+`BASE_VER_DOWN` by one update (pre-approved, once), and waits again.
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
-need IMAGE_ARN VER_SMALL ARTIFACT LOG_GROUP
-_ver() { try aws lambda-microvms get-microvm-image-version --image-identifier "$IMAGE_ARN" --image-version "$1" --query '[state,status]' --output text
- [ "$RC" = 0 ] || return 3; echo "$(date -u +%T) $1 $OUT"; case "$OUT" in "SUCCESSFUL ACTIVE") return 0;; PENDING*|IN_PROGRESS*) return 1;; esac; return 2; }
-if ! (poll 1200 15 "image version $VER_SMALL" _ver "$VER_SMALL"); then
- aws logs filter-log-events --log-group-name "$LOG_GROUP" --limit 50 --query 'events[].message' --output text || true
- die "the Small version did not build"
+need IMAGE_ARN IMAGE_NAME VER_SMALL ARTIFACT BASE_ARN BUILD_ROLE_ARN LOG_GROUP RUN
+lv image wait-version -id "$IMAGE_ARN" -version "$VER_SMALL" -timeout 20m -interval 15s
+if [ "$RC" = 6 ] && [ -z "${BASE_STEPPED_DOWN:-}" ] && [ -n "${BASE_VER_DOWN:-}" ]; then
+ finding "Small version $VER_SMALL failed to build from base ${BASE_VER_USED}: $(jq -r '.StateReason // empty' <<<"$OUT"); stepping down to $BASE_VER_DOWN"
+ try aws logs filter-log-events --log-group-name "$LOG_GROUP" --limit 50 --query 'events[].message' --output text; [ "$RC" = 0 ] && printf '%s\n' "$OUT" | tail -n 20
+ rec VER_SMALL_FAILED "$VER_SMALL"
+ intent microvm-image-version "$IMAGE_NAME" "token=$IMAGE_NAME-update-small-2" "base=$BASE_VER_DOWN"
+ lv image update -id "$IMAGE_ARN" -description "Task 17 minimal hook image, small, run $RUN, base $BASE_VER_DOWN" \
+ -artifact "$ARTIFACT" -base "$BASE_ARN" -base-version "$BASE_VER_DOWN" -build-role "$BUILD_ROLE_ARN" \
+ -hooks "$T17/image/hooks.json" -log-group "$LOG_GROUP" -memory 2048 -client-token "$IMAGE_NAME-update-small-2"; must
+ rec VER_SMALL "$(jq -r .ImageVersion <<<"$OUT")"; rec BASE_VER_USED "$BASE_VER_DOWN"; rec BASE_STEPPED_DOWN yes
+ lv image wait-version -id "$IMAGE_ARN" -version "$VER_SMALL" -timeout 20m -interval 15s
fi
-aws lambda-microvms get-microvm-image-version --image-identifier "$IMAGE_ARN" --image-version "$VER_SMALL" --output json > "$T17/out/3.8-small.json"
-jq -e --arg a "$ARTIFACT" '[.cpuConfigurations[].architecture] == ["X86_64"] and [.resources[].minimumMemoryInMiB] == [2048] and .additionalOsCapabilities == ["ALL"] and .codeArtifact.uri == $a and .hooks.port == 9000' "$T17/out/3.8-small.json" >/dev/null || die "the Small version differs: $(jq -c '{cpuConfigurations,resources,additionalOsCapabilities,codeArtifact,hooks}' "$T17/out/3.8-small.json")"
-jq -c '{imageVersion,state,status,tags}' "$T17/out/3.8-small.json"
+if [ "$RC" != 0 ]; then
+ try aws logs filter-log-events --log-group-name "$LOG_GROUP" --limit 50 --query 'events[].message' --output text; [ "$RC" = 0 ] && printf '%s\n' "$OUT" | tail -n 20
+ die "the Small version did not build; the image is needed"
+fi
+lv image get-version -id "$IMAGE_ARN" -version "$VER_SMALL"
+if [ "$RC" = 0 ]; then
+ printf '%s\n' "$OUT" > "$T17/out/3.8-small.json"
+ jq -e --arg a "$ARTIFACT" '([.CpuConfigurations[].Architecture] == ["X86_64"]) and ([.Resources[].MinimumMemoryInMiB] == [2048])
+ and (.AdditionalOsCapabilities == ["ALL"]) and (.CodeArtifact.Value == $a) and (.Hooks.Port == 9000)' "$T17/out/3.8-small.json" >/dev/null \
+ || finding "the Small version differs from what the adapter checks: $(jq -c '{CpuConfigurations,Resources,AdditionalOsCapabilities,CodeArtifact,Hooks}' "$T17/out/3.8-small.json")"
+ jw "FACT Small version: $(jq -c '{ImageVersion,State,Status,Tags}' "$T17/out/3.8-small.json")"
+else finding "Small version read failed: ${ECODE:-rc$RC}"; fi
jw "TIMING image-small-built"
```
-- Expected: `SUCCESSFUL ACTIVE`, then the exact fields the adapter's image check reads
- (`checkImageVersion`). The version's `tags` are recorded as read (U19).
+- Expected: `SUCCESSFUL ACTIVE`; the fields the adapter's image check reads (`checkImageVersion`)
+ match, or each difference is a FINDING (the adapter then refuses the version, and the contract
+ shows it).
+- Abort if: no Small version builds, after the one step down.
### 3.9 Large version by one update, then both versions checked
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
-need IMAGE_ARN IMAGE_NAME ARTIFACT BASE_ARN BASE_VER BUILD_ROLE_ARN LOG_GROUP VER_SMALL RUN
+need IMAGE_ARN IMAGE_NAME ARTIFACT BASE_ARN BASE_VER_USED BUILD_ROLE_ARN LOG_GROUP VER_SMALL RUN
intent microvm-image-version "$IMAGE_NAME" "token=$IMAGE_NAME-update-1"
-try aws lambda-microvms update-microvm-image --image-identifier "$IMAGE_ARN" --description "Task 17 minimal hook image, large, run $RUN" \
- --code-artifact "uri=$ARTIFACT" --base-image-arn "$BASE_ARN" --base-image-version "$BASE_VER" \
- --build-role-arn "$BUILD_ROLE_ARN" --cpu-configurations '[{"architecture":"X86_64"}]' \
- --resources '[{"minimumMemoryInMiB":4096}]' --additional-os-capabilities '["ALL"]' \
- --hooks "file://$T17/image/hooks.json" --logging "{\"cloudWatch\":{\"logGroup\":\"$LOG_GROUP\"}}" \
- --client-token "$IMAGE_NAME-update-1" --output json; must
+lv image update -id "$IMAGE_ARN" -description "Task 17 minimal hook image, large, run $RUN" \
+ -artifact "$ARTIFACT" -base "$BASE_ARN" -base-version "$BASE_VER_USED" -build-role "$BUILD_ROLE_ARN" \
+ -hooks "$T17/image/hooks.json" -log-group "$LOG_GROUP" -memory 4096 -client-token "$IMAGE_NAME-update-1"; must
printf '%s\n' "$OUT" > "$T17/out/3.9-image.json"
-rec VER_LARGE "$(jq -r .imageVersion "$T17/out/3.9-image.json")"
-[ "$VER_LARGE" != "$VER_SMALL" ] || die "the update returned the Small version"
-_ver() { try aws lambda-microvms get-microvm-image-version --image-identifier "$IMAGE_ARN" --image-version "$1" --query '[state,status]' --output text
- [ "$RC" = 0 ] || return 3; echo "$(date -u +%T) $1 $OUT"; case "$OUT" in "SUCCESSFUL ACTIVE") return 0;; PENDING*|IN_PROGRESS*) return 1;; esac; return 2; }
-poll 1200 15 "image version $VER_LARGE" _ver "$VER_LARGE"
-aws lambda-microvms get-microvm-image-version --image-identifier "$IMAGE_ARN" --image-version "$VER_LARGE" --output json > "$T17/out/3.9-large.json"
-jq -e '[.cpuConfigurations[].architecture] == ["X86_64"] and [.resources[].minimumMemoryInMiB] == [4096] and .additionalOsCapabilities == ["ALL"]' "$T17/out/3.9-large.json" >/dev/null || die "the Large version differs"
-get _v aws lambda-microvms get-microvm-image-version --image-identifier "$IMAGE_ARN" --image-version "$VER_SMALL" --query '[state,status]' --output text; [ "$_v" = "SUCCESSFUL ACTIVE" ] || die "the Small version is no longer SUCCESSFUL ACTIVE (U14)"
-get st aws lambda-microvms get-microvm-image --image-identifier "$IMAGE_ARN" --query state --output text; case "$st" in CREATED|UPDATED) ;; *) die "image state $st";; esac
-get _v aws lambda-microvms list-tags --resource "$IMAGE_ARN" --query 'Tags.run' --output text; [ "$_v" = "$RUN" ] || die "image tags missing"
-aws lambda-microvms list-microvm-image-versions --image-identifier "$IMAGE_ARN" --query 'items[].[imageVersion,state,status,resources[0].minimumMemoryInMiB]' --output text
+rec VER_LARGE "$(jq -r .ImageVersion "$T17/out/3.9-image.json")"
+[ "$VER_LARGE" != "$VER_SMALL" ] || finding "the update returned the Small version $VER_SMALL"
+lv image wait-version -id "$IMAGE_ARN" -version "$VER_LARGE" -timeout 20m -interval 15s
+if [ "$RC" = 0 ]; then
+ lv image get-version -id "$IMAGE_ARN" -version "$VER_LARGE"
+ if [ "$RC" = 0 ]; then
+ jq -e '([.CpuConfigurations[].Architecture] == ["X86_64"]) and ([.Resources[].MinimumMemoryInMiB] == [4096]) and (.AdditionalOsCapabilities == ["ALL"])' <<<"$OUT" >/dev/null \
+ || finding "the Large version differs: $(jq -c '{CpuConfigurations,Resources,AdditionalOsCapabilities}' <<<"$OUT")"
+ else finding "Large version read failed: ${ECODE:-rc$RC}"; fi
+else finding "the Large version did not build (rc $RC, ${ECODE:-}); no Large VM is ever launched, so the run goes on"; fi
+fact_lv "Small version after the update" "SUCCESSFUL ACTIVE" '"\(.State) \(.Status)"' image get-version -id "$IMAGE_ARN" -version "$VER_SMALL"
+lv image get -id "$IMAGE_ARN"
+if [ "$RC" = 0 ]; then
+ case "$(jq -r .State <<<"$OUT")" in CREATED|UPDATED) ;; *) finding "image state $(jq -r .State <<<"$OUT")";; esac
+ [ "$(jq -r '.Tags.run // empty' <<<"$OUT")" = "$RUN" ] || finding "image tags: $(jq -c .Tags <<<"$OUT")"
+else finding "image read failed: ${ECODE:-rc$RC}"; fi
```
-- Expected: two versions, both `SUCCESSFUL ACTIVE`, 2048 and 4096. No Large VM is launched; the
- Large version exists so the config maps both sizes and the image check reads it.
-- Abort if: any check fails.
+- Expected: two versions, both `SUCCESSFUL ACTIVE`, 2048 and 4096 MiB; tags present. No Large VM is
+ launched; the Large version exists so the config maps both sizes. Every difference is a FINDING.
+- Abort if: the update call itself fails (S.2 reconciles an uncertain reply).
---
@@ -1151,8 +1188,8 @@ intent sns-topic "$TOPIC_NAME"
try aws sns create-topic --name "$TOPIC_NAME" --tags Key=purpose,Value=$TAGV Key=run,Value=$RUN --query TopicArn --output text; must
[ "$OUT" = "arn:aws:sns:eu-west-1:$ACCOUNT:$TOPIC_NAME" ] || die "topic ARN [$OUT]"
rec TOPIC_ARN "$OUT"
-get _v aws sns list-tags-for-resource --resource-arn "$TOPIC_ARN" --query "Tags[?Key=='run'].Value" --output text; [ "$_v" = "$RUN" ] || die "topic tags missing"
-get _v aws sns list-subscriptions-by-topic --topic-arn "$TOPIC_ARN" --query 'length(Subscriptions)' --output text; [ "$_v" = 0 ] || die "the new topic has subscriptions"
+fact_eq "topic run tag" "$RUN" aws sns list-tags-for-resource --resource-arn "$TOPIC_ARN" --query "Tags[?Key=='run'].Value" --output text
+fact_eq "topic subscription count" 0 aws sns list-subscriptions-by-topic --topic-arn "$TOPIC_ARN" --query 'length(Subscriptions)' --output text
```
- 0.4 proved the name did not exist, so `create-topic`'s idempotent return cannot be someone else's
@@ -1270,23 +1307,27 @@ database to `aws:640012953448:eu-west-1` (R28) and proves the SNS topic takes st
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
+ok=yes
start_ctl "$T17/bin/controller" audit-only
-ctl_ready
-grep -F 'launches enabled: false' "$T17/controller.log" || die "the controller did not report launches off"
-! grep -F 'hosted controller: network audit failed' "$T17/controller.log" || die "the log shows a failed network audit"
+if (ctl_ready); then
+ grep -F 'launches enabled: false' "$T17/controller.log" || finding "the controller did not report launches off"
+ if grep -F 'hosted controller: network audit failed' "$T17/controller.log"; then finding "the log shows a failed network audit"; ok=no; fi
+else finding "the audit-only controller did not become ready (see controller.log)"; ok=no; fi
stop_ctl
dbread "select action, reason from audit where action in ('provider_bound','network_audit_passed','network_audit_failed') order by id"
-n=$(dbread "select count(*) from audit where action='network_audit_failed'"); [ "$n" = 0 ] || die "$n network audit failures"
-n=$(dbread "select count(*) from audit where action='network_audit_passed'"); [ "$n" -ge 1 ] || die "no network audit passed"
-dbread "select namespace from provider_binding" | grep -qx "aws:$ACCOUNT:eu-west-1" || die "database not bound to aws:$ACCOUNT:eu-west-1"
-jw "AUDIT passed before any launch"
+n=$(dbread "select count(*) from audit where action='network_audit_failed'"); [ "$n" = 0 ] || { finding "$n network audit failures"; ok=no; }
+n=$(dbread "select count(*) from audit where action='network_audit_passed'"); [ "$n" -ge 1 ] || { finding "no network audit passed"; ok=no; }
+dbread "select namespace from provider_binding" | grep -qx "aws:$ACCOUNT:eu-west-1" || finding "database not bound to aws:$ACCOUNT:eu-west-1"
+rec AUDIT_OK "$ok"
+[ "$ok" = yes ] && jw "AUDIT passed before any launch" || echo "the audit did not pass: sections 7 and 8 will be skipped"
```
- Expected: ready within 4 minutes with `network_audit_passing 1`, and no
`hosted controller: network audit failed; launches refused` line in the log; `provider_bound` and at least one
`network_audit_passed` row, no failure rows; clean stop, exit status 0.
-- Abort if: any check fails; the audit's failure row names the property (and the qualified ARN, if
- `VersionArn` differs: U3).
+- If the audit does not pass, each failed check is a FINDING (the failure row names the property)
+ and `AUDIT_OK` is `no`: sections 7 and 8, which need a ready controller, are skipped as FINDINGs;
+ 6 and 9 do not use the controller and still run.
---
@@ -1296,10 +1337,11 @@ Runs after 9.A to 9.F (client-token behaviour known, facts VMs settled).
### 6.1 Run it, then settle every VM it made
-The test runs with `go test -json`, so each line of output carries the subtest it belongs to. A
-passing run is handled first. A failing run is accepted only if every failed subtest is one of the
-two approved exceptions and its own output holds exactly the approved failure; nothing outside the
-subtest's output (such as 9.A's result) is used to classify it.
+The test runs with `go test -json`, so each line of output carries the subtest it belongs to. The
+contract runs to completion (Paul, 2026-11-28); every VM it made is settled afterwards (a hard stop
+if one cannot be). Each failed subtest then becomes a FINDING with its own messages, labelled
+"known" when it is one of the two failures the adapter is expected to show, from its own output
+only.
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
@@ -1310,48 +1352,36 @@ export EQUIPO_HOSTED_LIVE_CONFIG="$T17/live.json"
J="$T17/out/6-contract.json"
if gotest "$J" -tags hostedlive ./internal/isolatedjob/awsjob -run TestLiveContract -count=1 -v -json -timeout 60m; then rc=0; else rc=$?; fi
settle_all
-[ -s "$J" ] || die "no test output"
+[ -s "$J" ] || { finding "the contract wrote no test output (rc $rc)"; exit 0; }
jq -R -r 'fromjson? | select(.Action == "output") | .Output' "$J" > "$T17/out/6-contract.log"
-! grep -E "microvm id is missing or malformed|microvm id is malformed|empty or malformed ref" "$T17/out/6-contract.log" || die "the adapter refused a MicroVM ID as malformed (R36): stop and ask"
-grep -E 'visibility: Get showed new VM |list lag: List showed running VM ' "$T17/out/6-contract.log" || die "the contract logged no visibility or list-lag lines"
+if grep -E "microvm id is missing or malformed|microvm id is malformed|empty or malformed ref" "$T17/out/6-contract.log"; then finding "the adapter refused a MicroVM ID as malformed (R36)"; fi
+grep -E 'visibility: Get showed new VM |list lag: List showed running VM ' "$T17/out/6-contract.log" || finding "the contract logged no visibility or list-lag lines"
top=$(jq -R -r 'fromjson? | select(.Test == "TestLiveContract" and (.Action == "pass" or .Action == "fail")) | .Action' "$J")
-if [ "$rc" = 0 ]; then
- [ "$top" = pass ] || die "go test exited 0 but TestLiveContract did not pass ([$top])"
- jw "CONTRACT pass"; echo "contract PASS"; exit 0
-fi
-[ "$top" = fail ] || die "go test failed (rc $rc) outside TestLiveContract ([$top]): build error, panic or timeout"
+if [ "$rc" = 0 ] && [ "$top" = pass ]; then jw "CONTRACT pass"; echo "contract PASS"; exit 0; fi
+[ "$top" = fail ] || finding "go test ended with rc $rc outside TestLiveContract ([$top]): build error, panic or timeout"
fails=$(jq -R -r 'fromjson? | select(.Action == "fail" and (.Test // "" | startswith("TestLiveContract/"))) | .Test' "$J" | sort -u)
-[ -n "$fails" ] || die "TestLiveContract failed with no failed subtest"
sub_out() { jq -R -r --arg t "$1" 'fromjson? | select(.Test == $t and .Action == "output") | .Output' "$J" | grep -E '^\s+contract\.go:[0-9]+: ' | grep -vE 'contract\.go:[0-9]+: (visibility|list lag): ' || true; }
for f in $fails; do
- msgs=$(sub_out "$f"); n=$(grep -c . <<<"$msgs" || true)
- echo "$f: $msgs"
+ msgs=$(sub_out "$f"); n=$(grep -c . <<<"$msgs" || true); label=other
case "$f" in
TestLiveContract/StopUnknownRef)
- [ "$n" = 1 ] && grep -qE 'Stop\(contract-never-launched-[0-9a-f]+\) of a ref the provider never held = .*ValidationException.*, want nil$' <<<"$msgs" \
- || die "StopUnknownRef failed for a reason other than the approved ValidationException";;
+ [ "$n" = 1 ] && grep -qE 'Stop\(contract-never-launched-[0-9a-f]+\) of a ref the provider never held = .*ValidationException.*, want nil$' <<<"$msgs" && label="known: ValidationException for an unknown ref (U11)";;
TestLiveContract/ChangedSpecConflicts)
- [ "$n" = 1 ] && grep -qE 'Launch with the same attempt and a new bootstrap = \("", .*(ConflictException|ValidationException).*\), want ErrConflict$' <<<"$msgs" \
- || die "ChangedSpecConflicts failed for a reason other than an unmapped Conflict or Validation refusal with no VM";;
- *) die "contract subtest $f failed";;
+ [ "$n" = 1 ] && grep -qE 'Launch with the same attempt and a new bootstrap = \("", .*(ConflictException|ValidationException).*\), want ErrConflict$' <<<"$msgs" && label="known: refusal not mapped to ErrConflict";;
esac
+ finding "contract $f failed [$label]: $(tr '\n' ' ' <<<"$msgs")"
done
-jw "FINDING contract failures within the approved exceptions: $(tr '\n' ' ' <<<"$fails")"
-echo "contract: approved exceptions only: $fails"
+echo "contract finished with $(wc -w <<<"$fails") failed subtests, each recorded as a FINDING"
```
- Expected: `contract PASS`, and `settled: N VMs recorded` (about 7 contract VMs, each with a
15-minute maximum duration). The `visibility: Get showed new VM ...` and `list lag: List showed
running VM ...` lines are the measured delays (the pre-flight's 60 s and 30 s are guesses).
-- Approved exceptions, recorded as findings for an adapter fix after the run (not a pass), each
- only with exactly one failure line in its own output:
- - `StopUnknownRef`: `Stop(contract-never-launched-<hex>) of a ref the provider never held = <error
- naming ValidationException>, want nil` (U11).
- - `ChangedSpecConflicts`: `Launch with the same attempt and a new bootstrap = ("", <error naming
- ConflictException or ValidationException>), want ErrConflict`: AWS refused the changed request
- and no VM was returned, but the adapter did not map the refusal to `ErrConflict`.
-- Abort if: any other failure (another subtest, another message, a second VM, a throttling or other
- provider error, a build error, panic or timeout), or `settle_all` cannot settle.
+- Known failures (each still a FINDING, for an adapter fix after the run), each only with exactly
+ one failure line in its own output: `StopUnknownRef` with a `ValidationException` for a ref AWS
+ never issued (U11); `ChangedSpecConflicts` where AWS refused the changed request, no VM was
+ returned, and the adapter did not map the refusal to `ErrConflict`.
+- Hard stop only if: a VM it made cannot be settled.
---
@@ -1361,16 +1391,18 @@ echo "contract: approved exceptions only: $fails"
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
+if [ "${AUDIT_OK:-}" != yes ]; then finding "section 7 skipped: the 5.6 audit did not pass"; rec SKIP_7 yes; exit 0; fi
scan >/dev/null; [ -z "$LIVE" ] || die "live VMs of this image: $LIVE"
start_ctl "$T17/bin/controller" sequence EQUIPO_HOSTED_ENABLED=1
-ctl_ready
-grep -F 'launches enabled: true' "$T17/controller.log" || die "launches are not enabled"
+if ! (ctl_ready); then finding "the controller did not become ready; section 7 skipped"; stop_ctl; rec SKIP_7 yes; exit 0; fi
+grep -F 'launches enabled: true' "$T17/controller.log" || finding "the controller did not report launches enabled"
```
### 7.2 Driver sequence: launch Small, drain, quiescent, suspend, resume, stop with proof
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
+if [ -n "${SKIP_7:-}" ]; then echo "section 7 skipped"; exit 0; fi
. "$T17/driver.env"
ctl_alive || die "the controller is not running"
jw "PHASE sequence start"
@@ -1380,49 +1412,56 @@ grep -E 'attempt |launch:|running:|pause:|suspended:|resume:|stop:|timings:' "$T
harvest_ctl
stop_ctl
settle_all
-! grep -hE "microvm id is missing or malformed|microvm id is malformed|empty or malformed ref" "$T17/out/7.2-sequence.log" "$T17/controller.log" || die "a MicroVM ID was refused as malformed (R36): stop and ask"
-[ "$rc" = 0 ] || die "TestLiveControllerSequence failed"
-att=$(grep -oE 'attempt task17-[0-9a-f]+' "$T17/out/7.2-sequence.log" | head -n 1 | cut -d' ' -f2); rec SEQ_ATTEMPT "$att"
-dbread "select attempt_id, state, vm_ref, epoch, pause_generation, stop_proof_json from jobs where attempt_id='$SEQ_ATTEMPT'"
-dbread "select action, reason from audit where attempt_id='$SEQ_ATTEMPT' order by id"
+if grep -hE "microvm id is missing or malformed|microvm id is malformed|empty or malformed ref" "$T17/out/7.2-sequence.log" "$T17/controller.log"; then finding "a MicroVM ID was refused as malformed (R36)"; fi
+[ "$rc" = 0 ] || finding "TestLiveControllerSequence failed (rc $rc); see 7.2-sequence.log"
+att=$(grep -oE 'attempt task17-[0-9a-f]+' "$T17/out/7.2-sequence.log" | head -n 1 | cut -d' ' -f2 || true)
+if [ -n "$att" ]; then
+ rec SEQ_ATTEMPT "$att"
+ dbread "select attempt_id, state, vm_ref, epoch, pause_generation, stop_proof_json from jobs where attempt_id='$SEQ_ATTEMPT'"
+ dbread "select action, reason from audit where attempt_id='$SEQ_ATTEMPT' order by id"
+else finding "the sequence log names no attempt"; fi
```
- Expected: PASS and the `timings:` line (launch call a few seconds; `to_running` up to about a
minute, since states are read once per 60 s pass; resume epoch one above the launch epoch;
`stop_to_proof` about 2 to 3 minutes, R17). The job row is `stopped` with stop proof; its audit
rows show launch, drain, quiescent, suspend, resume and stop in order.
-- Abort if: FAIL (the controller is already stopped and VMs settled by this block).
+- A FAIL, a missing attempt or odd evidence is a FINDING; the controller is stopped and every VM
+ settled either way.
### 7.3 Crash between the provider call and transaction 2: the launch step
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
+if [ -n "${SKIP_7:-}" ]; then echo "section 7 skipped"; exit 0; fi
. "$T17/driver.env"
rec CRASH_ATTEMPT "task17-crash-$(openssl rand -hex 4)"
rec CRASH_START "$(date -u +%FT%T)"
start_ctl "$T17/bin/controller-crash" crash EQUIPO_HOSTED_ENABLED=1 EQUIPO_HOSTED_CRASH_AFTER_LAUNCH=1
-ctl_ready
-grep -F 'EQUIPO_HOSTED_CRASH_AFTER_LAUNCH=1' "$T17/controller.log" || die "the crash switch is not on"
+if ! (ctl_ready); then finding "the crash-build controller did not become ready; 7.3 and 7.4 skipped"; stop_ctl; rec SKIP_74 yes; exit 0; fi
+grep -F 'EQUIPO_HOSTED_CRASH_AFTER_LAUNCH=1' "$T17/controller.log" || finding "the crash switch is not reported on"
export EQUIPO_HOSTED_LIVE_ATTEMPT="$CRASH_ATTEMPT" EQUIPO_HOSTED_LIVE_CRASH_STEP=launch
if gotest "$T17/out/7.3-launch.log" -tags hostedlive ./internal/hostedclient -run 'TestLiveCrashRecovery$' -count=1 -v -timeout 10m; then rc=0; else rc=$?; fi
+[ "$rc" = 0 ] || finding "the launch step failed (rc $rc); see 7.3-launch.log"
_exited() { [ -s "$T17/controller.exit" ] && return 0; return 1; }
-poll 60 2 "crash-build controller exit" _exited
-[ "$(cat "$T17/controller.exit")" = 137 ] || die "exit status $(cat "$T17/controller.exit"), want 137"
-listeners; [ -z "$LST" ] || die "listeners still open: $LST"
+if ! (poll 60 2 "crash-build controller exit" _exited); then finding "the crash-build controller did not exit after the launch"; fi
+stop_ctl
+[ "$(cat "$T17/controller.exit" 2>/dev/null || true)" = 137 ] || finding "crash-build exit status $(cat "$T17/controller.exit" 2>/dev/null || echo unknown), want 137"
harvest_ctl
-vm=$(grep -oE "provider launched mvm-[0-9A-Za-z-]+ for $CRASH_ATTEMPT" "$T17/controller.log" | tail -n 1 | cut -d' ' -f3)
+vm=$(grep -oE "provider launched mvm-[0-9A-Za-z-]+ for $CRASH_ATTEMPT" "$T17/controller.log" | tail -n 1 | cut -d' ' -f3 || true)
+if [ -z "$vm" ]; then finding "the crash log names no launched VM; 7.4 skipped"; rec SKIP_74 yes; settle_all; exit 0; fi
rec CRASH_VM "$vm"
vm_get "$CRASH_VM"; echo "crash VM $CRASH_VM: $VST"
-case "$VST" in PENDING|RUNNING) ;; *) die "crash VM state $VST";; esac
-[ "$rc" = 0 ] || die "the launch step failed (see 7.3-launch.log)"
-jw "CRASH controller exited 137 after launching $CRASH_VM"
+case "$VST" in PENDING|RUNNING) ;; *) finding "crash VM state $VST";; esac
+jw "CRASH controller exited after launching $CRASH_VM"
```
- Expected: the launch fails in transport (the test passes); exit status 137; the log line
`crash point: the provider launched <vm> for <attempt>; exiting before the Ref is saved`; the VM
`PENDING` or `RUNNING`. If the launch is refused because no audit has passed recently, `ctl_ready`
was not satisfied; that cannot happen after it returned, so it is an abort.
-- Abort if: the controller answered the launch, exit status is not 137, or no VM was launched.
+- The controller answering the launch, another exit status, or no launched VM is a FINDING; 7.4
+ is then skipped if there is no VM to recover. Every VM is settled.
### 7.4 Restart without the crash switch; Replay claims the one VM
@@ -1432,11 +1471,12 @@ second reaper pass, about 60 s after start (pre-flight concern 2).
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
+if [ -n "${SKIP_7:-}" ] || [ -n "${SKIP_74:-}" ]; then echo "7.4 skipped"; settle_all; exit 0; fi
. "$T17/driver.env"
need CRASH_ATTEMPT CRASH_VM CRASH_START
start_ctl "$T17/bin/controller" recover EQUIPO_HOSTED_ENABLED=1
-ctl_ready
-tr '\0' '\n' < "/proc/$(ctl_pid)/environ" | grep -q '^EQUIPO_HOSTED_CRASH_AFTER_LAUNCH=' && die "the crash switch is set"
+if ! (ctl_ready); then finding "the restarted controller did not become ready; 7.4 skipped"; stop_ctl; settle_all; exit 0; fi
+if tr '\0' '\n' < "/proc/$(ctl_pid)/environ" | grep -q '^EQUIPO_HOSTED_CRASH_AFTER_LAUNCH='; then finding "the crash switch is set on the restart; 7.4 skipped"; stop_ctl; settle_all; exit 0; fi
export EQUIPO_HOSTED_LIVE_ATTEMPT="$CRASH_ATTEMPT" EQUIPO_HOSTED_LIVE_CRASH_STEP=recover \
EQUIPO_HOSTED_LIVE_OPERATOR_KEY_ID=task17-operator EQUIPO_HOSTED_LIVE_OPERATOR_KEY_FILE="$T17/keys/operator.key"
if gotest "$T17/out/7.4-recover.log" -tags hostedlive ./internal/hostedclient -run 'TestLiveCrashRecovery$' -count=1 -v -timeout 15m; then rc=0; else rc=$?; fi
@@ -1444,12 +1484,13 @@ grep -E 'recover:|listed vm|stop:' "$T17/out/7.4-recover.log" || true
harvest_ctl
stop_ctl
settle_all
-[ "$rc" = 0 ] || die "the recover step failed"
-grep -q "recover: job $CRASH_ATTEMPT holds vm $CRASH_VM" "$T17/out/7.4-recover.log" || die "the job does not hold $CRASH_VM"
+[ "$rc" = 0 ] || finding "the recover step failed (rc $rc); see 7.4-recover.log"
+grep -q "recover: job $CRASH_ATTEMPT holds vm $CRASH_VM" "$T17/out/7.4-recover.log" || finding "the job does not hold $CRASH_VM"
+grep -F 'restart stop requested, elapsed time unknown' "$T17/controller.log" && finding "the restart stopped a job for unknown elapsed time"
scan >/dev/null
n=$(awk -F'\t' -v t="$CRASH_START" '$3 >= t' "$T17/last_scan.tsv" | wc -l)
awk -F'\t' -v t="$CRASH_START" '$3 >= t' "$T17/last_scan.tsv"
-[ "$n" = 1 ] || die "$n VMs of this image started since the crash launch, want 1"
+[ "$n" = 1 ] || finding "$n VMs of this image started since the crash launch, want 1"
dbread "select attempt_id, state, vm_ref, stop_proof_json from jobs where attempt_id='$CRASH_ATTEMPT'"
dbread "select action, reason from audit where attempt_id='$CRASH_ATTEMPT' order by id"
```
@@ -1457,7 +1498,7 @@ dbread "select action, reason from audit where attempt_id='$CRASH_ATTEMPT' order
- Expected: PASS; no `restart stop requested, elapsed time unknown` line in the log; the job holds `$CRASH_VM`, the same ID the crashed controller launched; one VM
for the attempt and no unowned live VM; stop with proof; exactly one VM of this image started
since 7.3 began; audit rows show the intent, the replay, the saved Ref and the stop.
-- Abort if: any check fails.
+- Each failed check is a FINDING; the controller is stopped and every VM settled.
---
@@ -1467,15 +1508,16 @@ dbread "select action, reason from audit where attempt_id='$CRASH_ATTEMPT' order
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
+if [ "${AUDIT_OK:-}" != yes ]; then finding "section 8 skipped: the 5.6 audit did not pass"; rec SKIP_8 yes; exit 0; fi
scan >/dev/null; [ -z "$LIVE" ] || die "live VMs of this image: $LIVE"
start_ctl "$T17/bin/controller" orphan
-ctl_ready
-metrics | grep -E '^equipo_hosted_jobs\{state="waiting"\} 0$' || die "a waiting intent exists, so R22 would defer the orphan"
+if ! (ctl_ready); then finding "the controller did not become ready; section 8 skipped"; stop_ctl; rec SKIP_8 yes; exit 0; fi
+if ! metrics | grep -qE '^equipo_hosted_jobs\{state="waiting"\} 0$'; then finding "a waiting intent exists, so R22 would defer the orphan; section 8 skipped"; stop_ctl; rec SKIP_8 yes; exit 0; fi
printf 'orphan' > "$T17/out/payload-orphan"
-rec ORPHAN_TOKEN "t17-orphan-$RUN"
+rec ORPHAN_TOKEN "$NAME-orphan"
rec ORPHAN_PLANTED "$(date -u +%FT%TZ)"
launch orphan "$ORPHAN_TOKEN" 1800 "$T17/out/payload-orphan"
-[ "$L_RC" = 0 ] || die "the orphan launch failed: $L_CODE"
+if [ "$L_RC" != 0 ]; then finding "the orphan launch failed: ${L_CODE:-rc$L_RC} ${L_MSG}; section 8 skipped"; stop_ctl; rec SKIP_8 yes; exit 0; fi
rec ORPHAN_VM "$L_ID"
```
@@ -1490,49 +1532,50 @@ within a minute or two after that.
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
+if [ -n "${SKIP_8:-}" ]; then echo "section 8 skipped"; exit 0; fi
need ORPHAN_VM ORPHAN_PLANTED
P=$(date -d "$ORPHAN_PLANTED" +%s)
while :; do
now=$(date +%s)
- [ $(( now - P )) -lt 900 ] || die "no stop seen by P+15:00 (last state ${VST:-none})"
- ctl_alive || die "the controller stopped"
+ if [ $(( now - P )) -ge 900 ]; then stop_ctl; vm_end "$ORPHAN_VM"; die "the orphan was not stopped by P+15:00 (last state ${VST:-none}): a VM alive outside its step"; fi
+ ctl_alive || { finding "the controller stopped while watching the orphan"; vm_end "$ORPHAN_VM"; settle_all; exit 0; }
vm_get "$ORPHAN_VM"
echo "P+$(( (now - P) / 60 )):$(printf %02d $(( (now - P) % 60 ))) $VST"
case "$VST" in
- PENDING|RUNNING|ERROR:ThrottlingException) ;;
TERMINATING|TERMINATED|NOTFOUND) break;;
- *) die "orphan state $VST";;
+ PENDING|RUNNING) ;;
+ *) finding "orphan read: $VST";;
esac
sleep 20
done
-[ $(( now - P )) -ge 600 ] || die "the orphan was stopped before the 10-minute grace"
+[ $(( now - P )) -ge 600 ] || finding "the orphan was stopped before the 10-minute grace (P+$(( now - P ))s)"
jw "ORPHAN stopped by the reaper at P+$(( now - P ))s"
-metrics | grep -E 'orphan'
-metrics | grep -qE '^equipo_hosted_alerts_total\{kind="orphan_stopped",result="sent"\} 1$' || die "no orphan_stopped alert sent"
-grep -F 'hosted controller: orphan VM stopped' "$T17/controller.log" | grep -F "$ORPHAN_VM" || die "no orphan-stopped log line for $ORPHAN_VM"
-! grep -F 'hosted controller: orphan VM left running for a dispatched launch intent' "$T17/controller.log" | grep -qF "$ORPHAN_VM" || die "the orphan was deferred (R22)"
+metrics | grep -E 'orphan' || true
+metrics | grep -qE '^equipo_hosted_alerts_total\{kind="orphan_stopped",result="sent"\} 1$' || finding "no orphan_stopped alert counted as sent"
+grep -F 'hosted controller: orphan VM stopped' "$T17/controller.log" | grep -F "$ORPHAN_VM" || finding "no orphan-stopped log line for $ORPHAN_VM"
+if grep -F 'hosted controller: orphan VM left running for a dispatched launch intent' "$T17/controller.log" | grep -qF "$ORPHAN_VM"; then finding "the orphan was deferred (R22)"; fi
stop_ctl
vm_end "$ORPHAN_VM"
settle_all
dbread "select action, reason from audit where action like 'orphan%' order by id"
-n=$(dbread "select count(*) from audit where action='orphan_stopped' and reason like '%$ORPHAN_VM%'"); [ "$n" = 1 ] || die "$n orphan_stopped rows for $ORPHAN_VM"
+n=$(dbread "select count(*) from audit where action='orphan_stopped' and reason like '%$ORPHAN_VM%'"); [ "$n" = 1 ] || finding "$n orphan_stopped audit rows for $ORPHAN_VM"
```
- Expected: `RUNNING` until about P+11:00 to P+12:30; then the alert metric, the controller's log
line `hosted controller: orphan VM stopped` naming the VM (no deferral line), one `orphan_seen` and one `orphan_stopped` audit row for it; the VM ends.
-- Abort if: stopped before P+10:00; no stop seen by P+15:00, whatever the reads returned (the
- deadline is checked first on every iteration, so repeated throttling cannot extend it); or any
- evidence check fails.
+- Hard stop: no stop seen by P+15:00, whatever the reads returned (the deadline is checked first on
+ every iteration); the block stops the controller and ends the VM first. A stop before P+10:00 and
+ any missing evidence are FINDINGs.
---
## 9. Facts to record (R7)
9.A to 9.F run before section 6, with no controller running. Every VM here comes from the `launch`
-helper (Small, `NO_INGRESS`, the qualified connector, a short maximum duration as AWS's backstop),
-which journals the intent first and records any VM ID returned. Each experiment either ends every
-VM it made, confirmed, or aborts before the next experiment starts. Only the listed error codes
-count as results; any other error aborts.
+helper (livectl `vm run`: Small, `NO_INGRESS`, the qualified connector, a short maximum duration as
+AWS's backstop), which journals the intent first and records any VM ID returned. Each experiment
+ends every VM it made, confirmed, before the next one starts. The expected codes are recorded as
+results; any other code is a FINDING and the run goes on.
### 9.A Client token: same request, then changed request
@@ -1541,81 +1584,91 @@ set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
! ctl_alive || die "the controller is running"
scan >/dev/null; [ -z "$LIVE" ] || die "live VMs of this image: $LIVE"
printf 'task17-a' > "$T17/out/payload-a"; printf 'task17-b' > "$T17/out/payload-b"
-rec TOKEN_A "t17-token-$RUN"
+rec TOKEN_A "$NAME-token-a"
rec A1_BEFORE "$(date -u +%FT%T.%3NZ)"
launch A1 "$TOKEN_A" 900 "$T17/out/payload-a"
rec A1_AFTER "$(date -u +%FT%T.%3NZ)"
-[ "$L_RC" = 0 ] || die "A1 failed: $L_CODE"
+[ "$L_RC" = 0 ] || die "A1 failed (${L_CODE:-rc$L_RC}: ${L_MSG}); every VM step needs a launch (U21: a qualified egress ARN)"
rec VM_A "$L_ID"
jw "FIRST-VM-ID $VM_A (length ${#VM_A})"; echo "first real MicroVM ID: $VM_A (length ${#VM_A})"
-[[ "$VM_A" =~ ^[A-Za-z0-9-]{1,128}$ ]] || { vm_end "$VM_A"; die "MicroVM ID [$VM_A] is outside R36's form; the adapter refuses it (fails closed): stop and ask"; }
+[[ "$VM_A" =~ ^[A-Za-z0-9-]{1,128}$ ]] || finding "MicroVM ID [$VM_A] is outside R36's form; the adapter will refuse it (fails closed)"
launch A2 "$TOKEN_A" 900 "$T17/out/payload-a"
if [ "$L_RC" = 0 ] && [ "$L_ID" = "$VM_A" ]; then rec A2_RESULT same-vm
-elif [ "$L_RC" = 0 ]; then vm_end "$L_ID"; vm_end "$VM_A"; rec A2_RESULT "new-vm:$L_ID"; die "a replay of the same request made a second VM"
-else vm_end "$VM_A"; die "A2 failed: $L_CODE"; fi
+elif [ "$L_RC" = 0 ]; then vm_end "$L_ID"; rec A2_RESULT "new-vm:$L_ID"; finding "a replay of the same request made a second VM ($L_ID, ended)"
+else rec A2_RESULT "refused:${L_CODE:-rc$L_RC}"; finding "a replay of the same request was refused: ${L_CODE:-rc$L_RC} ${L_MSG}"; fi
launch A3 "$TOKEN_A" 900 "$T17/out/payload-b"
if [ "$L_RC" != 0 ]; then
- case "$L_CODE" in ConflictException|ValidationException) rec A3_RESULT "refused:$L_CODE";; *) vm_end "$VM_A"; die "A3 failed with $L_CODE";; esac
+ rec A3_RESULT "refused:${L_CODE:-rc$L_RC}"; jw "FACT A3 message: ${L_MSG}"
+ case "$L_CODE" in ConflictException|ValidationException) ;; *) finding "a changed request with a used token was refused with ${L_CODE:-rc$L_RC}";; esac
elif [ "$L_ID" = "$VM_A" ]; then rec A3_RESULT same-vm
-else vm_end "$L_ID"; rec A3_RESULT "new-vm:$L_ID"; jw "FINDING a changed request with a used token made a second VM"; fi
-cat "$T17/out/launch-A3.err"
+else vm_end "$L_ID"; rec A3_RESULT "new-vm:$L_ID"; finding "a changed request with a used token made a second VM ($L_ID, ended)"; fi
echo "A2=$A2_RESULT A3=$A3_RESULT"
```
-- Expected: the first real MicroVM ID is recorded with its length and fits R36's form (1 to 128
- characters of `[A-Za-z0-9-]`); if it does not, the adapter would refuse every ID, so the run stops
- and asks. A2 returns `VM_A` (one attempt, one VM). A3 is refused with `ConflictException` or
+- Expected: A1 launches (the first test that RunMicrovm takes a qualified egress ARN, U21; a refusal
+ stops the run, since every VM step needs it). The first real MicroVM ID is recorded with its
+ length; outside R36's form it is a FINDING (the adapter will refuse it). A2 returns `VM_A` (one
+ attempt, one VM). A3 is refused with `ConflictException` or
`ValidationException`; the exact message is recorded.
- A3 answered with `VM_A` (AWS ignores the body on replay) or with a new VM (ended at once) are
- results, recorded; with a new VM, 6.1's `ChangedSpecConflicts` exception no longer applies.
+ results; a new VM, or any code other than the two above, is also a FINDING.
- `VM_A` stays up for 9.B to 9.D.
-### 9.B startedAt, the NO_INGRESS literal, the Date header
+### 9.B startedAt, the echoes, the Date header
```sh
set -euo pipefail; . "${TMPDIR:?}/equipo-t17/env.sh"; guard
need VM_A A1_BEFORE A1_AFTER CONN_QARN
-echo "run call: $A1_BEFORE to $A1_AFTER; reply: $(jq -c '{state,startedAt}' "$T17/out/launch-A1.json")"
-_running() { try aws lambda-microvms get-microvm --microvm-identifier "$VM_A" --query '[state,startedAt]' --output text
- [ "$RC" = 0 ] || return 3; echo "$(date -u +%T.%3N) $OUT"; case "$OUT" in RUNNING*) return 0;; PENDING*) return 1;; esac; return 2; }
-poll 120 1 "VM_A to RUNNING" _running
-aws lambda-microvms get-microvm --microvm-identifier "$VM_A" --output json > "$T17/out/9.B-get.json"
-jq -e --arg n "$NO_INGRESS" --arg c "$CONN_QARN" '.ingressNetworkConnectors == [$n] and .egressNetworkConnectors == [$c] and .maximumDurationInSeconds == 900 and (.executionRoleArn == null) and (.idlePolicy == null)' "$T17/out/9.B-get.json" >/dev/null || die "VM_A settings differ: $(jq -c '{ingressNetworkConnectors,egressNetworkConnectors,maximumDurationInSeconds,executionRoleArn,idlePolicy}' "$T17/out/9.B-get.json")"
-for op in get list; do
- if [ "$op" = get ]; then try aws lambda-microvms get-microvm --microvm-identifier "$VM_A" --debug; else try aws lambda-microvms list-microvms --image-identifier "$IMAGE_ARN" --debug; fi
- must
- d=$(printf '%s' "$ERR" | grep -m1 'Response headers' | grep -oE "'[Dd]ate': '[^']*'" || true)
- if [ -n "$d" ]; then rec "DATE_HEADER_$op" "present"; echo "$op: $d"; else rec "DATE_HEADER_$op" inconclusive; echo "$op: measurement inconclusive"; fi
- ERR=""
-done
+echo "run call: $A1_BEFORE to $A1_AFTER; reply: $(jq -c '{State,StartedAt}' "$T17/out/launch-A1.json")"
+_running() { lv vm get -id "$VM_A"; [ "$RC" = 0 ] || return 1
+ echo "$(date -u +%T.%3N) $(jq -r '"\(.State) \(.StartedAt)"' <<<"$OUT")"; case "$(jq -r .State <<<"$OUT")" in RUNNING) return 0;; PENDING) return 1;; esac; return 2; }
+if ! (poll 120 1 "VM_A to RUNNING" _running); then
+ finding "VM_A did not reach RUNNING within 120 s"; vm_end "$VM_A"; rec VM_A_ENDED "$(date -u +%FT%TZ)"; exit 0
+fi
+lv vm get -id "$VM_A"
+if [ "$RC" = 0 ]; then
+ printf '%s\n' "$OUT" > "$T17/out/9.B-get.json"
+ jw "FACT VM_A echoes: $(jq -c '{IngressNetworkConnectors,EgressNetworkConnectors,MaximumDurationInSeconds,ExecutionRoleArn,IdlePolicy,StartedAt}' "$T17/out/9.B-get.json")"
+ [ "$(jq -c .IngressNetworkConnectors "$T17/out/9.B-get.json")" = "[\"$NO_INGRESS\"]" ] || finding "ingress echo is $(jq -c .IngressNetworkConnectors "$T17/out/9.B-get.json")"
+ [ "$(jq -c .EgressNetworkConnectors "$T17/out/9.B-get.json")" = "[\"$CONN_QARN\"]" ] || finding "egress echo is $(jq -c .EgressNetworkConnectors "$T17/out/9.B-get.json")"
+ sv=$(jq -r '.ResultMetadata.ServerTime // empty' "$T17/out/9.B-get.json")
+ if [ -n "$sv" ]; then rec DATE_HEADER_get present; jw "FACT GetMicrovm Date header: $sv"; else rec DATE_HEADER_get absent; finding "GetMicrovm reply has no Date header (provider age unknown)"; fi
+else finding "VM_A read failed: ${ECODE:-rc$RC}"; fi
+rec DATE_HEADER_list "not measured: livectl prints no metadata for lists"
```
-- Expected: `startedAt` is in the PENDING reply; record how it relates to the call window and to the
- first RUNNING read, and whether it changes. The VM shows exactly the `NO_INGRESS` literal, the
- qualified connector, 900 s, no role, no idle policy. Only the `Date` value is kept from the debug
- output (the debug text is never written to a file the run keeps).
-- If the grep finds nothing, the result is "measurement inconclusive" (U12), not "absent"; the
- method is not changed during the run.
+- Expected: `StartedAt` is in the PENDING reply; record how it relates to the call window and to the
+ first RUNNING read. The ingress, egress, maximum duration, execution role and idle policy echoes
+ are recorded as facts (Paul, 2026-11-28); an ingress or egress echo other than what was sent is a
+ FINDING. The Date header is livectl's `ResultMetadata.ServerTime` for GetMicrovm; livectl prints
+ no metadata for lists, so the List header is recorded as not measured.
### 9.C Resume on RUNNING; suspend on SUSPENDED; a second resume
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
need VM_A
-r() { try aws lambda-microvms "$1" --microvm-identifier "$VM_A"; echo "$1: rc=$RC code=${ECODE:-none} ${ERR}"; }
-r resume-microvm
-if [ "$RC" = 0 ]; then rec RESUME_ON_RUNNING accepted; elif [ "$ECODE" = ConflictException ]; then rec RESUME_ON_RUNNING ConflictException; else vm_end "$VM_A"; die "resume on RUNNING: $ECODE"; fi
-rec SUSPEND_AT "$(date -u +%FT%T.%3NZ)"; r suspend-microvm; must
-vm_wait "$VM_A" SUSPENDED 180 RUNNING SUSPENDING
-r suspend-microvm
-if [ "$RC" = 0 ]; then rec SUSPEND_ON_SUSPENDED accepted; elif [ "$ECODE" = ConflictException ]; then rec SUSPEND_ON_SUSPENDED ConflictException; else vm_end "$VM_A"; die "suspend on SUSPENDED: $ECODE"; fi
-rec RESUME_AT "$(date -u +%FT%T.%3NZ)"; r resume-microvm; must
-vm_get "$VM_A"; before=$VST
-r resume-microvm
-case "$before" in SUSPENDED) when=during-first-resume;; RUNNING) when=after-first-resume;; *) when="unknown:$before";; esac
-if [ "$RC" = 0 ]; then rec SECOND_RESUME "accepted:$when"; elif [ "$ECODE" = ConflictException ]; then rec SECOND_RESUME "ConflictException:$when"; else vm_end "$VM_A"; die "second resume: $ECODE"; fi
-vm_wait "$VM_A" RUNNING 180 SUSPENDED
-echo "resume-on-running=$RESUME_ON_RUNNING suspend-on-suspended=$SUSPEND_ON_SUSPENDED second-resume=$SECOND_RESUME"
+if [ -n "${VM_A_ENDED:-}" ]; then finding "9.C skipped: VM_A has ended"; exit 0; fi
+r() { lv vm "$1" -id "$VM_A"; echo "$1: rc=$RC code=${ECODE:-none} ${LV_MSG}"; }
+res() { if [ "$RC" = 0 ]; then echo accepted; elif [ "$ECODE" = ConflictException ]; then echo ConflictException; else echo "other:${ECODE:-rc$RC}"; fi; }
+r resume; rec RESUME_ON_RUNNING "$(res)"
+case "$RESUME_ON_RUNNING" in other:*) finding "resume on RUNNING: $RESUME_ON_RUNNING ${LV_MSG}";; esac
+rec SUSPEND_AT "$(date -u +%FT%T.%3NZ)"; r suspend
+if [ "$RC" = 0 ] && (vm_wait "$VM_A" SUSPENDED 180 RUNNING SUSPENDING); then
+ r suspend; rec SUSPEND_ON_SUSPENDED "$(res)"
+ case "$SUSPEND_ON_SUSPENDED" in other:*) finding "suspend on SUSPENDED: $SUSPEND_ON_SUSPENDED";; esac
+ rec RESUME_AT "$(date -u +%FT%T.%3NZ)"; r resume
+ [ "$RC" = 0 ] || finding "resume of a SUSPENDED VM: ${ECODE:-rc$RC} ${LV_MSG}"
+ vm_get "$VM_A"; before=$VST
+ r resume
+ case "$before" in SUSPENDED) when=during-first-resume;; RUNNING) when=after-first-resume;; *) when="unknown:$before";; esac
+ rec SECOND_RESUME "$(res):$when"
+ case "$SECOND_RESUME" in other:*) finding "second resume: $SECOND_RESUME";; esac
+else finding "suspend of VM_A failed or it did not reach SUSPENDED (rc $RC ${ECODE:-})"; fi
+if ! (vm_wait "$VM_A" RUNNING 180 SUSPENDED SUSPENDING); then
+ finding "VM_A is not RUNNING after 9.C; ending it"; vm_end "$VM_A"; rec VM_A_ENDED "$(date -u +%FT%TZ)"
+fi
+echo "resume-on-running=$RESUME_ON_RUNNING suspend-on-suspended=${SUSPEND_ON_SUSPENDED:-not run} second-resume=${SECOND_RESUME:-not run}"
```
- Expected: resume on RUNNING is a `ConflictException` (R4; if accepted, the adapter's mapping is
@@ -1630,10 +1683,10 @@ echo "resume-on-running=$RESUME_ON_RUNNING suspend-on-suspended=$SUSPEND_ON_SUSP
set -euo pipefail; . "${TMPDIR:?}/equipo-t17/env.sh"; guard
probe() { local n=$1
head -c "$n" /dev/zero | tr '\0' x > "$T17/out/payload-$n"; [ "$(wc -c < "$T17/out/payload-$n")" = "$n" ] || die "payload file size"
- launch "P$n" "t17-p$n-$RUN" 120 "$T17/out/payload-$n"
+ launch "P$n" "$NAME-p$n" 120 "$T17/out/payload-$n"
if [ "$L_RC" = 0 ]; then vm_end "$L_ID"; rec "PAYLOAD_$n" accepted
- elif [ "$L_CODE" = ValidationException ]; then rec "PAYLOAD_$n" "refused:ValidationException"; cat "$T17/out/launch-P$n.err"
- else die "payload $n: $L_CODE"; fi; }
+ elif [ "$L_CODE" = ValidationException ]; then rec "PAYLOAD_$n" "refused:ValidationException"; jw "FACT payload $n message: ${L_MSG}"
+ else rec "PAYLOAD_$n" "refused:${L_CODE:-rc$L_RC}"; finding "payload $n refused with ${L_CODE:-rc$L_RC}: ${L_MSG}"; fi; }
probe 4096; probe 4097
if [ "$PAYLOAD_4097" = accepted ]; then probe 16384; probe 16385; fi
echo "4096=$PAYLOAD_4096 4097=$PAYLOAD_4097 16384=${PAYLOAD_16384:-not run} 16385=${PAYLOAD_16385:-not run}"
@@ -1648,13 +1701,15 @@ echo "4096=$PAYLOAD_4096 4097=$PAYLOAD_4097 16384=${PAYLOAD_16384:-not run} 1638
```sh
set -euo pipefail; . "${TMPDIR:?}/equipo-t17/env.sh"; guard
need VM_A TOKEN_A
-vm_end "$VM_A"; rec VM_A_ENDED "$(date -u +%FT%TZ)"
-try aws lambda-microvms terminate-microvm --microvm-identifier "$VM_A"
-if [ "$RC" = 0 ]; then rec TERMINATE_AGAIN ok; elif [ "$ECODE" = ResourceNotFoundException ]; then rec TERMINATE_AGAIN ResourceNotFoundException; else die "terminate again: $ECODE"; fi
+vm_end "$VM_A"; [ -n "${VM_A_ENDED:-}" ] || rec VM_A_ENDED "$(date -u +%FT%TZ)"
+lv vm terminate -id "$VM_A"
+if [ "$RC" = 0 ]; then rec TERMINATE_AGAIN ok; elif [ "$ECODE" = ResourceNotFoundException ]; then rec TERMINATE_AGAIN ResourceNotFoundException
+else rec TERMINATE_AGAIN "other:${ECODE:-rc$RC}"; finding "terminate of an ended VM: ${ECODE:-rc$RC} ${LV_MSG}"; fi
launch E1 "$TOKEN_A" 900 "$T17/out/payload-a"
if [ "$L_RC" = 0 ] && [ "$L_ID" = "$VM_A" ]; then rec E1_RESULT same-ended-vm
elif [ "$L_RC" = 0 ]; then vm_end "$L_ID"; rec E1_RESULT "new-vm:$L_ID"
-else case "$L_CODE" in ConflictException|ValidationException|ResourceNotFoundException) rec E1_RESULT "refused:$L_CODE";; *) die "E1: $L_CODE";; esac; fi
+else rec E1_RESULT "refused:${L_CODE:-rc$L_RC}"
+ case "$L_CODE" in ConflictException|ValidationException|ResourceNotFoundException) jw "FACT E1 message: ${L_MSG}";; *) finding "E1 replay refused with ${L_CODE:-rc$L_RC}: ${L_MSG}";; esac; fi
settle_all
echo "E1=$E1_RESULT"
```
@@ -1684,7 +1739,8 @@ need TOKEN_A VM_A A1_BEFORE
launch G1 "$TOKEN_A" 900 "$T17/out/payload-a"
if [ "$L_RC" = 0 ] && [ "$L_ID" = "$VM_A" ]; then rec G1_RESULT same-ended-vm
elif [ "$L_RC" = 0 ]; then vm_end "$L_ID"; rec G1_RESULT "new-vm:$L_ID"
-else case "$L_CODE" in ConflictException|ValidationException|ResourceNotFoundException) rec G1_RESULT "refused:$L_CODE";; *) die "G1: $L_CODE";; esac; fi
+else rec G1_RESULT "refused:${L_CODE:-rc$L_RC}"
+ case "$L_CODE" in ConflictException|ValidationException|ResourceNotFoundException) jw "FACT G1 message: ${L_MSG}";; *) finding "G1 replay refused with ${L_CODE:-rc$L_RC}: ${L_MSG}";; esac; fi
settle_all
echo "G1=$G1_RESULT, $(( ( $(date +%s) - $(date -d "$A1_BEFORE" +%s) ) / 60 )) minutes after the token's first use"
```
@@ -1693,7 +1749,7 @@ echo "G1=$G1_RESULT, $(( ( $(date +%s) - $(date -d "$A1_BEFORE" +%s) ) / 60 )) m
least that long. Then run 9.F once more.
**R7 record** (one line each in the progress file): A2, A3 (with message), E1, G1 (with minutes);
-Date header for Get and List (present or inconclusive); startedAt in PENDING and its relation to the
+the Date header on Get (and List: not measured); startedAt in PENDING and its relation to the
call and to RUNNING; resume on RUNNING; suspend on SUSPENDED; second resume with its label; payload
results (ASCII); the NO_INGRESS literal as echoed; TERMINATED visibility bounds; contract visibility
and List lag.
@@ -1705,28 +1761,27 @@ and List lag.
Runs after 9.G, or on Paul's word after a safe stop. Dependency order. Each deletion is confirmed by
a direct read before the next dependency is touched, and recorded with `deleted`.
-### 10.1 No controller, no VM, then the image and both versions
+### 10.1 No controller, no VM, then the image (all its versions)
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
stop_ctl
if have IMAGE_ARN; then
settle_all
-try aws lambda-microvms delete-microvm-image --image-identifier "$IMAGE_ARN" --output json
-[ "$RC" = 0 ] || die "delete image: ${ECODE:-rc$RC} $ERR (a ConflictException is a stop: U8)"
-_img() { try aws lambda-microvms list-microvm-images --query "items[?imageArn=='$IMAGE_ARN'].state" --output json
- [ "$RC" = 0 ] || return 3; OUT=$(jq -r 'join(" ")' <<<"$OUT") || return 3; echo "$(date -u +%T) listed state: [${OUT}]"
- case "$OUT" in ""|DELETED) return 0;; DELETING) return 1;; esac; return 2; }
+lv image delete -id "$IMAGE_ARN"
+[ "$RC" = 0 ] || die "image delete: ${ECODE:-rc$RC} ${LV_MSG:-$ERR} (a ConflictException is a stop: U8)"
+_img() { lv image list -name "$IMAGE_NAME"; [ "$RC" = 0 ] || return 1
+ OUT=$(jq -r --arg a "$IMAGE_ARN" '[.Items[] | select(.ImageArn == $a) | .State] | join(" ")' <<<"$OUT") || return 3
+ echo "$(date -u +%T) listed state: [${OUT}]"; case "$OUT" in ""|DELETED) return 0;; DELETING) return 1;; esac; return 2; }
poll 900 15 "image deleted" _img
-for vv in VER_SMALL VER_LARGE; do
- have "$vv" || continue; v=${!vv}
- try aws lambda-microvms get-microvm-image-version --image-identifier "$IMAGE_ARN" --image-version "$v" --query state --output text
- if [ "$RC" = 0 ]; then [ "$OUT" = DELETED ] || die "version $v is $OUT"; else expect_err ResourceNotFoundException; fi
- deleted microvm-image-version "$IMAGE_ARN:$v"
-done
deleted microvm-image "$IMAGE_ARN"
-try aws lambda-microvms list-microvms --output json; must
-printf '%s' "$OUT" | jq -e --arg a "$IMAGE_ARN" '[.items[] | select(.imageArn == $a and .state != "TERMINATED")] | length == 0' >/dev/null || die "a live VM of the deleted image"
+for vv in VER_SMALL_FAILED VER_SMALL VER_LARGE; do
+ [ -n "${!vv:-}" ] || continue; v=${!vv}
+ lv image get-version -id "$IMAGE_ARN" -version "$v"
+ if { [ "$RC" = 0 ] && [ "$(jq -r .State <<<"$OUT")" = DELETED ]; } || { [ "$RC" != 0 ] && [ "$ECODE" = ResourceNotFoundException ]; }; then
+ deleted microvm-image-version "$IMAGE_ARN:$v"
+ else finding "version $v after the image delete: rc $RC ${ECODE:-} $(jq -r '.State // empty' <<<"$OUT" 2>/dev/null || true)"; fi
+done
fi
```
@@ -1735,16 +1790,42 @@ fi
```sh
set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"; guard
if have CONN_ARN; then
-need VPC
-try aws lambda-core delete-network-connector --identifier "$CONN_ARN"; must
-_conn() { try aws lambda-core get-network-connector --identifier "$CONN_ARN" --query State --output text
- if [ "$RC" = 0 ]; then echo "$(date -u +%T) $OUT"; case "$OUT" in DELETING|ACTIVE|INACTIVE) return 1;; esac; return 2; fi
- [ "$ECODE" = ResourceNotFoundException ] && return 0; return 3; }
-poll 900 15 "connector deleted" _conn
-deleted connector "$CONN_ARN"
-_enis() { try aws ec2 describe-network-interfaces --filters Name=vpc-id,Values="$VPC" --query 'length(NetworkInterfaces)' --output json
- [ "$RC" = 0 ] || return 3; echo "$(date -u +%T) interfaces in VPC: $OUT"; [ "$OUT" = 0 ] && return 0; return 1; }
-poll 2400 30 "connector interfaces gone" _enis
+need VPC SUBNET OPERATOR_ROLE
+conn_delete() { lv connector delete -id "$CONN_ARN"
+ [ "$RC" = 0 ] || [ "$ECODE" = ResourceNotFoundException ] || die "connector delete: ${ECODE:-rc$RC} ${LV_MSG:-$ERR}"; }
+conn_gone() { lv connector wait-gone -id "$CONN_ARN" -timeout 40m -interval 15s; CG_RC=$RC; CG_CODE=$ECODE
+ echo "wait-gone: rc $CG_RC ${CG_CODE:-} $(jq -c '{State,StateReason}' <<<"$OUT" 2>/dev/null || true)"; }
+# enis_gone SECONDS: 0 when no interface is left in the VPC within SECONDS; 1 when some are left at the bound.
+enis_gone() { local end=$(( $(date +%s) + $1 ))
+ while :; do
+ try aws ec2 describe-network-interfaces --filters Name=vpc-id,Values="$VPC" --query 'length(NetworkInterfaces)' --output json
+ [ "$RC" = 0 ] || die "interface count unreadable: ${ECODE:-rc$RC}"
+ echo "$(date -u +%T) interfaces in VPC: $OUT"; [ "$OUT" = 0 ] && return 0
+ [ "$(date +%s)" -lt "$end" ] || return 1
+ sleep 30
+ done; }
+conn_delete; conn_gone; ok=no
+if [ "$CG_RC" = 0 ]; then deleted connector "$CONN_ARN"; enis_gone 2400 && ok=yes
+elif [ "$CG_RC" = 6 ] && [ "$CG_CODE" = DELETE_FAILED ]; then :
+else die "connector wait-gone: rc $CG_RC ${CG_CODE:-}"; fi
+if [ "$ok" = no ]; then
+ finding "connector teardown needs the pre-approved fallback (wait-gone rc $CG_RC ${CG_CODE:-}, or interfaces left after 40 min)"
+ have OPERATOR_ROLE_ARN || die "no operator role to change"
+ A=arn:aws:ec2:eu-west-1:640012953448
+ cat > "$T17/iam/operator-delete-subnet.json" <<TEOF
+{"Version":"2012-10-17","Statement":[
+ {"Sid":"DeleteEniInThisSubnet","Effect":"Allow","Action":"ec2:DeleteNetworkInterface","Resource":"$A:network-interface/*",
+ "Condition":{"ArnEquals":{"ec2:Subnet":"$A:subnet/$SUBNET"}}}]}
+TEOF
+ jq -e . "$T17/iam/operator-delete-subnet.json" >/dev/null
+ aws iam put-role-policy --role-name "$OPERATOR_ROLE" --policy-name t17-connector-eni-delete --policy-document "file://$T17/iam/operator-delete-subnet.json"
+ rec OPERATOR_DELETE_FALLBACK "subnet condition only (Paul, 2026-11-28)"
+ echo "waiting 120 s for IAM propagation, then one more connector delete"; sleep 120
+ conn_delete; conn_gone
+ [ "$CG_RC" = 0 ] || die "the connector delete failed again after the fallback (rc $CG_RC ${CG_CODE:-}): hard stop"
+ grep -q $'\tDELETED connector '"$CONN_ARN"'$' "$JOURNAL" || deleted connector "$CONN_ARN"
+ enis_gone 2400 || die "interfaces are still in the VPC after the fallback: hard stop"
+fi
for e in $(awk -F'\t' '$2 ~ /^SERVICE-ENI / {split($2, a, " "); print a[2]}' "$JOURNAL"); do
gone0 "interface $e" aws ec2 describe-network-interfaces --filters Name=network-interface-id,Values="$e" --query 'length(NetworkInterfaces)' --output json
deleted service-eni "$e"
@@ -1752,8 +1833,10 @@ done
fi
```
-- Abort if: `DELETE_FAILED`, or interfaces remain after 40 minutes. Lambda's interfaces are never
- deleted by hand.
+- Pre-approved fallback (Paul, 2026-11-28): on `DELETE_FAILED`, or interfaces left after 40
+ minutes, the inline delete policy loses its `ec2:ManagedResourceOperator` condition (the subnet
+ condition stays), and after 120 s the connector delete is retried once. A second failure, or
+ interfaces still left, is a hard stop. Lambda's interfaces are never deleted by hand.
### 10.3 Network
@@ -1787,9 +1870,10 @@ fi
### 10.4 IAM roles
-The operator role may hold the narrow inline policy (2.1), or, after 2.2's fallback, the fallback's
-inline policy and the managed attachment. Each is removed if present; `NoSuchEntity` means it was
-never added.
+The operator role holds the managed attachment and the inline delete policy (2.1; 10.2's fallback
+rewrites the same policy name). The old narrow policy name is still tried, so a role left by an
+earlier revision is cleaned too. Each is removed if present; `NoSuchEntity` means it was never
+added.
```sh
set -euo pipefail; . "${TMPDIR:?}/equipo-t17/env.sh"; guard
@@ -1891,6 +1975,8 @@ set -euo pipefail; T17='<T17 printed by 0.2>'; . "$T17/env.sh"
no_unresolved
cut -f2- "$JOURNAL" | grep -vE '^(INTENT|CONTROLLER) ' > "$T17/journal-for-progress.txt"
wc -l "$T17/journal-for-progress.txt" "$VMS"
+echo "== every FINDING (the report lists each one):"
+awk -F'\t' '$2 ~ /^FINDING / {print $1, substr($2, 9)}' "$JOURNAL" | tee "$T17/findings.txt"
```
Paste `journal-for-progress.txt`, `vms.tsv`, the R7 lines and section 11.2's estimate into
@@ -1971,7 +2057,7 @@ for pair in "$OPERATOR_ROLE:OPERATOR_ROLE_ARN" "$BUILD_ROLE:BUILD_ROLE_ARN"; do
else unresolved "iam-role $r: ${ECODE:-rc$RC}"; fi
done
if pending connector "$CONN_NAME" CONN_ARN; then
- try aws lambda-core get-network-connector --identifier "$CONN_NAME" --output json
+ lv connector get -id "$CONN_NAME"
if [ "$RC" = 0 ] && [ "$(jq -r .Name <<<"$OUT")" = "$CONN_NAME" ]; then arn=$(jq -r .Arn <<<"$OUT"); arn_ok "$arn"; rec CONN_ARN "$arn"; rec CONN_ID "$(jq -r .Id <<<"$OUT")"
elif code_in ResourceNotFoundException; then absent "connector $CONN_NAME"
else unresolved "connector $CONN_NAME: ${ECODE:-rc$RC}"; fi
@@ -2017,28 +2103,20 @@ if pending s3-object "s3://$BUCKET/t17/app.zip" ARTIFACT; then
else unresolved "s3-object: head failed: ${ECODE:-rc$RC}"; fi
fi
if pending microvm-image "$IMAGE_NAME" IMAGE_ARN; then
- try aws lambda-microvms list-microvm-images --query "items[?name=='$IMAGE_NAME'].imageArn" --output json
- [ "$RC" != 0 ] || OUT=$(jq -r 'join(" ")' <<<"$OUT") || RC=99
+ lv image list -name "$IMAGE_NAME"
+ [ "$RC" != 0 ] || OUT=$(jq -r --arg n "$IMAGE_NAME" '[.Items[] | select(.Name == $n) | .ImageArn] | join(" ")' <<<"$OUT") || RC=99
if [ "$RC" != 0 ]; then unresolved "microvm-image $IMAGE_NAME: list failed: ${ECODE:-rc$RC}"
elif [ -z "$OUT" ]; then absent "microvm-image $IMAGE_NAME"
elif [ "$(wc -w <<<"$OUT")" != 1 ]; then unresolved "microvm-image $IMAGE_NAME: listed several: $OUT"
else arn=$OUT
[ "$arn" = "arn:aws:lambda:eu-west-1:$ACCOUNT:microvm-image:$IMAGE_NAME" ] || die "image ARN [$arn]"
rec IMAGE_ARN "$arn"
- try aws lambda-microvms list-tags --resource "$IMAGE_ARN" --query 'Tags.run' --output text
- if [ "$RC" = 0 ] && [ "$OUT" != "$RUN" ]; then
- try aws lambda-microvms tag-resource --resource "$IMAGE_ARN" --tags purpose=$TAGV,run=$RUN; [ "$RC" = 0 ] || unresolved "microvm-image: tagging failed: ${ECODE:-rc$RC}"
- elif [ "$RC" != 0 ]; then unresolved "microvm-image: tags unreadable: ${ECODE:-rc$RC}"; fi
+ lv image get -id "$IMAGE_ARN"
+ if [ "$RC" = 0 ] && [ "$(jq -r '.Tags.run // empty' <<<"$OUT")" != "$RUN" ]; then
+ finding "microvm-image: tags missing ($(jq -c .Tags <<<"$OUT")); livectl tags only at create"
+ elif [ "$RC" != 0 ]; then finding "microvm-image: tags unreadable: ${ECODE:-rc$RC}"; fi
fi
fi
-for pair in "2048:VER_SMALL" "4096:VER_LARGE"; do
- mem=${pair%%:*}; v=${pair#*:}
- [ -n "${IMAGE_ARN:-}" ] && [ -z "${!v:-}" ] || continue
- try aws lambda-microvms list-microvm-image-versions --image-identifier "$IMAGE_ARN" --output json
- if [ "$RC" != 0 ]; then unresolved "image version $mem MiB: ${ECODE:-rc$RC}"; continue; fi
- vs=$(jq -r --argjson m "$mem" '[.items[] | select(.resources[0].minimumMemoryInMiB == $m) | .imageVersion] | join(" ")' <<<"$OUT")
- case "$(wc -w <<<"$vs")" in 0) absent "image version $mem MiB";; 1) rec "$v" "$vs";; *) unresolved "image version $mem MiB: several: $vs";; esac
-done
if pending sns-topic "$TOPIC_NAME" TOPIC_ARN; then
t="arn:aws:sns:eu-west-1:$ACCOUNT:$TOPIC_NAME"
try aws sns list-topics --query "length(Topics[?TopicArn=='$t'])" --output json
@@ -2055,7 +2133,8 @@ fi
```
The extra IAM call here (`tag-role`, only when a role exists without its tags) is one of the role
-calls R37 covers.
+calls R37 covers. Image versions are not reconciled: they go with the image, which livectl deletes
+whole.
**S.3 VMs.** If the image was never created (no `IMAGE_ARN`, even after S.2), no VM can exist; the
block records the skip and ends (skip-never-created rule).
@@ -2185,68 +2264,66 @@ EOF
## 12. UNCONFIRMED items and placeholders
-### Settled since revision 1 (Astra's dispositions)
-
-- **U1, connector role trust:** the Web Functions networking guide prints it for the same connector
- mechanism (`lambda.amazonaws.com`, `sts:AssumeRole`); the plan uses it with `sts:TagSession` added
- and no `aws:SourceAccount` condition. A trust failure is a stop.
-- **Build role trust:** granting `sts:AssumeRole` and `sts:TagSession` covers both versions of the
- page (the live page shows the first only).
-- **U6, hooks:** `/ready` returning 200 signals readiness; the hook fields fit the models; run
- payload delivery is documented. A runtime hook failure is a stop.
-- **U9, connector interfaces:** the pinned SDK documents asynchronous interface cleanup on delete,
- then not found. The 15 and 40 minute bounds are ours; exhausting them is a stop.
-- **U15, billing service name:** removed with the Cost Explorer call (R33).
-- **U18, error codes, part settled (revision 3):** attempt 1 observed `ResourceNotFoundException`
- from `lambda-core get-network-connector` given an unknown name, `NoSuchEntity` from IAM
- `get-role` on a missing role, and the `An error occurred (<code>)` text the `try` helper parses.
- IAM `delete-role-policy` uses the same `NoSuchEntity` code (its model error is
- `NoSuchEntityException`). `NoSuchTagSet` for an untagged bucket is in the S3 API reference for
- `GetBucketTagging`. The S3 `404`, SNS `NotFound` and EC2 `Invalid*.NotFound` branches are gone:
- those checks now list and match. `get-microvm-image` takes an ARN or ID, not a name (observed);
- the plan no longer calls it by name.
-- **U20, process survival:** settled by R37: sandboxed calls kill their children on return, so the
- controller blocks run with the sandbox off, with PID files and identity checks; a missing
- controller is an abort.
-
-### Still unconfirmed, 15 (each is a stop point if it goes wrong; nothing is changed live)
-
-1. **U2. Operator role scoping.** Attempt 2: the narrow policy was refused at create time
- ("invalid ConnectorOperatorRole permissions", 21 s after the role was created); whether that was
- propagation or a missing permission is not known. 2.2 now retries after 120 s, then falls back to
- the managed policy plus a scoped inline delete (Paul, 2026-11-25); a third refusal is a stop.
- Whether the `ec2:ManagedResourceOperator` condition admits Lambda's interface deletions at
- teardown is unconfirmed: a `DELETE_FAILED` connector in 10.2 is a stop.
-2. **U3. Old CLI model.** The installed CLI's models lack `X86_64`, `VersionArn`, connector
- versions and two managed-version fields (confirmed); that the CLI passes `X86_64` through
- unvalidated is not confirmed. No CLI upgrade or flag change live.
-3. **U4. Base image availability** of `al2023-1` version 3 or later for x86_64 in this account and
- region.
-4. **U5. Container base image** `public.ecr.aws/lambda/microvms:al2023-minimal` has an x86_64
- variant. No other image is substituted.
-5. **U7. Build log group** used exclusively by the build; other groups are never deleted.
-6. **U8. Image deletion** with versions present: a `ConflictException` is a stop; there is no
- fallback.
-7. **U10. `eu-west-1a`** accepted for the subnet and connector. No other zone is tried.
-8. **U11. Malformed VM ID** on `terminate-microvm`: only the `ValidationException` branch is
- approved, and it is a recorded failure, not a pass.
-9. **U12. `--debug` output format** for the `Date` header; no match is "inconclusive".
-10. **U13. Tag index coverage** of MicroVM images and connectors; direct reads decide.
-11. **U14. Small version stays ACTIVE** after the update; checked as a gate in 3.9.
-12. **U16. Ireland rates** for snapshots, launch reads and image storage, and whether builds or
- connectors are billed; the worst case adds 20 % and counts builds as VM time.
-13. **U17. MicroVM ID format** (`mvm-` and the guide's pattern) for harvesting IDs from logs; the
- image-scoped scans are the authoritative inventory either way. 9.A records the first real ID;
- one outside R36's form is a stop.
-14. **U18. Lambda MicroVMs not-found code**, still a stop point: `ResourceNotFoundException` for
- `get-microvm` and `terminate-microvm` on a VM that is gone, and for `get-microvm-image-version`
- after the image is deleted. It is the documented 404 in the model and the API reference for
- each operation, but not yet observed. A different code aborts (fail closed).
-15. **U19. Image version tags:** whether versions carry the image's tags; recorded as read in 3.8,
- not required.
+### Settled by the attempts and revision 5
+
+- **U1, connector role trust:** `lambda.amazonaws.com` with `sts:AssumeRole` and `sts:TagSession`
+ was accepted (attempt 3).
+- **Build role trust:** granting both actions covers both versions of the AWS page.
+- **U2, create half:** the narrow operator policy is refused at create time even after 3.3 minutes
+ (attempt 3); the managed policy plus the scoped delete was accepted. 2.1 now uses it from the
+ start. The delete half is item 1 below.
+- **U3, old CLI model:** no Lambda call goes through the CLI any more (R40). livectl sends
+ `X86_64` and reads `Version`, `VersionArn`, `LatestVersionArn`, `Status` and
+ `SupportedCpuConfigurations` through the pinned SDK. Attempt 3's discovery confirmed that `<arn>:1`
+ reads `Version` 1, and that the unqualified body carries `LatestVersion` and `LatestVersionArn`
+ only.
+- **U6, hooks:** documented; a runtime hook failure shows up as a FINDING or as A1's stop.
+- **U9, connector interfaces:** connector delete took about 19 s (attempt 3). There were no
+ interfaces while ACTIVE, so cleanup with interfaces present is still item 1.
+- **U10, `eu-west-1a`:** accepted for the subnet (attempt 2) and the connector (attempt 3).
+- **U12, the Date header:** livectl reports it as `ResultMetadata.ServerTime`. lambda-core sends one
+ (attempt 3's discovery); GetMicrovm is measured in 9.B.
+- **U13, tag index:** the index lagged by up to a day after every teardown; direct reads decide
+ (attempts 2 and 3).
+- **U15, billing service name:** removed with Cost Explorer (R33).
+- **U18, part:** connector-by-name gives `ResourceNotFoundException`; IAM gives `NoSuchEntity`;
+ `NoSuchTagSet` is documented. Guessed S3, SNS and EC2 codes were replaced by list-and-match
+ checks.
+- **U20, process survival:** R37 (sandbox off, PID files, identity checks).
+
+### Still unconfirmed, 13
+
+Each is now either a stop only where safety or a later step depends on it, or a FINDING.
+
+1. **U2, delete half.** It is untested whether Lambda's interface deletion passes the
+ `ec2:ManagedResourceOperator` condition. 10.2's pre-approved fallback drops that condition
+ (keeping the subnet condition) and retries once; a second failure is a hard stop.
+2. **U4, base image version.** livectl now reads `Status` and x86_64 support. A failed create or
+ build steps down one version once (3.6 to 3.8). A second failure stops the run: the image is
+ needed.
+3. **U5, container base image** `public.ecr.aws/lambda/microvms:al2023-minimal` for x86_64. A build
+ failure takes the same step down; nothing else is substituted.
+4. **U7, build log group.** Other groups under the prefix are never deleted; 10.6 stops for Paul
+ (not in the ledger).
+5. **U8, image deletion.** A `ConflictException` from livectl `image delete` is a stop, since
+ teardown needs the image gone.
+6. **U11, an unknown VM ref** on terminate: now a FINDING (6.1 labels it "known").
+7. **U14, the Small version stays ACTIVE** after the update: a FINDING (3.9).
+8. **U16, Ireland rates** for snapshots, launch reads and image storage: an estimate assumption.
+9. **U17, MicroVM ID format:** 9.A records the first real ID; outside R36's form is a FINDING. The
+ image-scoped scans are the inventory either way.
+10. **U18, the Lambda MicroVMs not-found code** (`ResourceNotFoundException` for a gone VM) is
+ documented but not observed. It stays fail-closed only in `vm_end`, where proving a VM ended is
+ a safety check. Everywhere else a different code is a FINDING.
+11. **U19, image version tags:** recorded as read (3.8), a fact.
+12. **U21, a qualified egress ARN on RunMicrovm.** The adapter and the audit require it. A1 in 9.A
+ is the first launch; a refusal stops the run, since every VM step needs launches (Fable's
+ review).
+13. **U22, livectl's interface.** It is under Astra's review, and small interface changes may
+ follow. The plan is written against `livectl-usage.md` at `a36861a0`. Any change comes back
+ with the final `PIN_SHA`, and a livectl usage error is a hard stop, never improvised around.
### Placeholders
-None in the plan. `PIN_SHA` is `a7f505a0d69a2459062c83cb46baf7882e261c5f`; the controller and contract log
-lines grepped above are the exact texts in that commit (`internal/hostedctl/logs.go`,
-`internal/isolatedjob/isolatedjobtest/contract.go`).
+- **P1. `PIN_SHA`** in 0.1 and 0.2: the commit holding livectl after Astra's review, relayed by the
+ coordinator. Both blocks refuse to run until it is filled in.