| 1 | # Hosted runners slice 1a: progress and mutation checks |
| 2 | |
| 3 | ## Task 1 |
| 4 | |
| 5 | Retry `poll` on `EINTR` on Linux and Darwin (`internal/runner/containment/poll_unix.go`). |
| 6 | |
| 7 | | Mutation | Command | Observed failure | Restored | |
| 8 | | --- | --- | --- | --- | |
| 9 | | `pollRetry` returns on the first `EINTR` (`if e != unix.EINTR \|\| true`) | `go test ./internal/runner/containment -run 'TestPollRetriesEINTR' -count=1` | `poll_unix_test.go:23: interrupted poll not retried: n=0 err=interrupted system call calls=1` | yes, `-run 'TestPollRetr'` passes | |
| 10 | | Extra: the expired deadline reports the `EINTR` instead of a timeout (`return 0, e`) | `go test ./internal/runner/containment -run 'TestPollRetryKeepsDeadline' -count=1` | `poll_unix_test.go:36: retries outlived the timeout: n=0 err=interrupted system call after 120.617911ms` | yes, `-run 'TestPollRetr'` passes | |
| 11 | | Fix round 1: remove the zero-timeout cap (`else if false && tries >= zeroTimeoutTries`) | `go test ./internal/runner/containment -run 'TestPollRetryBoundsZeroTimeout' -count=1` | `poll_unix_test.go:38: endless interruption not bounded: n=0 err=<nil> calls=81` | yes, `-run 'TestPollRetr'` passes | |
| 12 | |
| 13 | ## Task 2 |
| 14 | |
| 15 | Tests in `internal/runner/containment` that read the source tree carry the `TestSource` prefix, so a compiled test binary run outside the tree skips them with `-test.skip '^TestSource'`. `TestSourceTestsAreNamed` parses every `*_test.go` in the package and fails if a function outside the prefix passes a relative string literal (directly or as the first part of a `filepath.Join`) to `os.ReadFile`, `os.Open`, `os.OpenFile`, `os.Stat`, `os.Lstat`, `os.ReadDir`, `os.DirFS` or `filepath.Glob`. |
| 16 | |
| 17 | | Mutation | Command | Observed failure | Restored | |
| 18 | | --- | --- | --- | --- | |
| 19 | | `TestBubblewrapPins` reads `../../../scripts/ci-box.json` again | `go test ./internal/runner/containment -run 'TestSourceTestsAreNamed' -count=1` | `helper_version_test.go:83: tests outside the TestSource prefix open relative paths: bubblewrap_pin_test.go:63 TestBubblewrapPins` | yes, `-run 'TestSourceTestsAreNamed'` passes | |
| 20 | |
| 21 | Compiled binary outside the tree: `go test -c` into `mktemp -d "$TMPDIR/hosted-XXXX"`, run from there with `-test.run TestBubblewrapPins -test.skip '^TestSource'`: `--- PASS: TestBubblewrapPins`. Directory removed. |
| 22 | |
| 23 | Whole binary outside the tree (fix round 1, HEAD 975997ff). Environment: docs-t1, user paulca, `TMPDIR=/home/paulca/.cache/tmp`, systemd user session present (`XDG_RUNTIME_DIR=/run/user/1001`), `/usr/bin/bwrap` is bubblewrap 0.11.0, sandbox off. Built with `CGO_ENABLED=0 go test -c -o "$d/containment.test" ./internal/runner/containment`, `d=$(mktemp -d "$TMPDIR/hosted-XXXX")` (`hosted-qAHZ`). Each run is `<binary> -test.skip '^TestSource' -test.v`, no `-test.run`; counts are top-level tests (84 ran each time; no `TestSource` test ran; none skipped). |
| 24 | |
| 25 | | cwd | binary given as | pass | fail | failures | |
| 26 | | --- | --- | --- | --- | --- | |
| 27 | | `$d` (outside the tree) | `./containment.test` | 81 | 3 | `TestNamespaceParentDeath`, `TestNamespaceRecoveryCrashBeforeExit`, `TestNamespaceOpenCodeBinaryAfterAttestation` | |
| 28 | | `$d` (outside the tree) | `$d/containment.test` | 83 | 1 | `TestNamespaceOpenCodeBinaryAfterAttestation` | |
| 29 | | `internal/runner/containment` (control) | `$d/containment.test` | 83 | 1 | `TestNamespaceOpenCodeBinaryAfterAttestation` | |
| 30 | | `internal/runner/containment` (control, `-test.run` on the two) | relative path to `$d/containment.test` | 0 | 2 | `TestNamespaceParentDeath`, `TestNamespaceRecoveryCrashBeforeExit` | |
| 31 | |
| 32 | Reasons, none a source read: |
| 33 | - `TestNamespaceOpenCodeBinaryAfterAttestation/second_name`: `listen unix /home/paulca/.cache/tmp/TestNamespace...second_name1945606201/002/tool/equipo.sock: bind: invalid argument`. The socket path is 109 bytes, over the Unix socket limit, because of the long `TMPDIR`. Environmental; fails the same inside the tree. |
| 34 | - `TestNamespaceParentDeath` and `TestNamespaceRecoveryCrashBeforeExit`: the re-executed child panics `namespace_mount_rejected` in `parentFixture` (`linux_test.go:412`), which passes `RunnerBinary: os.Args[0]`; a relative `os.Args[0]` is refused by the absolute-path mount rule. This follows how the binary is invoked, not where: an absolute path passes outside the tree, a relative path fails inside it. Fixed below. |
| 35 | |
| 36 | `rm -r "$d"`; `ls` confirms it is gone. |
| 37 | |
| 38 | Fix: `parentFixture` takes `RunnerBinary` from `os.Executable()` (panicking on its error, as the fixture already panics on others), so the run no longer depends on how the binary is started. Re-run on the same environment, new `mktemp -d "$TMPDIR/hosted-XXXX"` (`hosted-WVJD`): |
| 39 | |
| 40 | | cwd | binary given as | pass | fail | failures | |
| 41 | | --- | --- | --- | --- | --- | |
| 42 | | `$d` (outside the tree) | `./containment.test` | 83 | 1 | `TestNamespaceOpenCodeBinaryAfterAttestation` (socket path over the limit, environmental, left) | |
| 43 | |
| 44 | `--- PASS: TestNamespaceParentDeath (0.11s)`, `--- PASS: TestNamespaceRecoveryCrashBeforeExit (0.11s)`; no `TestSource` test ran; the directory is removed. In the tree, `go test ./internal/runner/containment -run 'TestNamespaceParentDeath|TestNamespaceRecoveryCrashBeforeExit|TestSourceTestsAreNamed' -count=1 -v` passes all three. |
| 45 | |
| 46 | ## Task 3 |
| 47 | |
| 48 | `TestNamespaceCgroupMoveKeepsMembership` asks `cgroupSkip` (in `internal/runner/containment/linux_test.go`) whether the `user@UID.service` cgroup exists. Where it does not, as inside a MicroVM, the test skips with `no systemd user session; production containment does not use cgroups`; with `EQUIPO_REQUIRE_USER_SESSION=1` it fails instead. A stat error other than "does not exist" fails either way. `make runner-namespace-test` sets `EQUIPO_REQUIRE_USER_SESSION=1`, so the CI host still fails loudly if its session goes away; `scripts/ci-test.py retried` passes the environment through to `go test` and to its retry. |
| 49 | |
| 50 | | Mutation | Command | Observed failure | Restored | |
| 51 | | --- | --- | --- | --- | |
| 52 | | `cgroupSkip` ignores `require` (`case require && false:`) | `go test ./internal/runner/containment -run 'TestCgroupSessionRule' -count=1` | `linux_test.go:264: no session required: cgroupSkip = (true, "no systemd user session; production containment does not use cgroups", false), want (false, "EQUIPO_REQUIRE_USER_SESSION=1 but no systemd user session at /sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service: file does not exist", true)` | yes, `-run 'TestCgroupSessionRule'` passes | |
| 53 | |
| 54 | On docs-t1 (bubblewrap 0.11.0, session cgroup present): `go test ./internal/runner/containment -run '^TestNamespaceCgroupMoveKeepsMembership$' -count=1 -v` gives `--- PASS: TestNamespaceCgroupMoveKeepsMembership (0.11s)`, and the same with `EQUIPO_REQUIRE_USER_SESSION=1` gives `--- PASS (0.13s)`. |
| 55 | |
| 56 | ## Task 5 |
| 57 | |
| 58 | New package `internal/isolatedjob`: the `Runner` interface, `LaunchSpec.Validate`, the state sets, `Clock` with `SystemClock()`, and `NetworkAudit.OK`. An attempt ID is 1 to 64 ASCII letters, digits or `-` (it becomes the AWS client token, which takes up to 128). Validate wraps `ErrInvalid` for every failure except an oversized bootstrap, which wraps `ErrBootstrapTooLarge`. |
| 59 | |
| 60 | | Mutation | Command | Observed failure | Restored | |
| 61 | | --- | --- | --- | --- | |
| 62 | | `unknown` is terminal (`case StateStopped, StateFailed, StateUnknown:`) | `go test ./internal/isolatedjob -run 'TestStateSets' -count=1` | `isolatedjob_test.go:141: State("unknown").Terminal() = true, want false` | yes, `-run 'TestStateSets'` passes | |
| 63 | | `>=` on the lifetime limit (`s.MaxLifetime >= limit`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:83: Validate = isolatedjob: invalid request: lifetime 8h0m0s must be above zero and at most 8h0m0s, want nil` (also the 1h provider-limit row) | yes, `-run 'TestLaunchSpecValidate'` passes | |
| 64 | | Extra: `OK` ignores missing egress (`missingFrom(want, a.EgressOnly)[:0]`) | `go test ./internal/isolatedjob -run 'TestNetworkAuditOK' -count=1` | `isolatedjob_test.go:195: OK = nil, want an error naming [egress]` (the missing-egress and nothing-seen rows) | yes, whole package passes | |
| 65 | |
| 66 | ### Task 5 fix round 1 |
| 67 | |
| 68 | Every guard now has a mutation. `SystemClock` takes its wall and elapsed sources through an unexported seam (`newSystemClock(now, since)`); `TestSystemClockWallJump` moves the wall clock back an hour while elapsed time moves forward, and `TestSystemClock` checks the real start keeps its monotonic reading. Each row was applied by a scratch script that replaced one exact string, ran the command, kept the first assertion line, wrote the original back and ran the command again. No row failed by a build error. |
| 69 | |
| 70 | | Mutation | Command | Observed failure | Restored | |
| 71 | | --- | --- | --- | --- | |
| 72 | | attempt id: empty accepted (`if len(id) > maxAttemptIDLen {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/attempt_id_empty` | yes, passes | |
| 73 | | attempt id: 65 chars accepted (`len(id) > maxAttemptIDLen+1 {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/attempt_id_65_chars` | yes, passes | |
| 74 | | attempt id: '_' accepted (`... c <= 'Z' \|\| c >= '0' && c <= '9' \|\| c == '-' \|\| c == '_') {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/attempt_id_underscore` | yes, passes | |
| 75 | | attempt id: space accepted (`... c <= 'Z' \|\| c >= '0' && c <= '9' \|\| c == '-' \|\| c == ' ') {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/attempt_id_space` | yes, passes | |
| 76 | | attempt id: non-ASCII bytes accepted (`...c <= 'Z' \|\| c >= '0' && c <= '9' \|\| c == '-' \|\| c >= 0x80) {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/attempt_id_non-ascii` | yes, passes | |
| 77 | | attempt id: '-' refused (`... c <= 'z' \|\| c >= 'A' && c <= 'Z' \|\| c >= '0' && c <= '9') {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:83: Validate = isolatedjob: invalid request: attempt id must be 1 to 64 letters, digits or '-', want nil` in `TestLaunchSpecValidate/good, TestLaunchSpecValidate/attempt_id_64_chars_at_limit and 27 more` | yes, passes | |
| 78 | | image: prefix not required (`if false && !ok \|\| len(hex) != 64 {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/image_no_prefix` | yes, passes | |
| 79 | | image: 65 hex accepted (`len(hex) < 64 {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/image_long` | yes, passes | |
| 80 | | image: 63 hex accepted (`len(hex) > 64 {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/image_short` | yes, passes | |
| 81 | | image: upper-case hex accepted (`... c <= '9' \|\| c >= 'a' && c <= 'f' \|\| c >= 'A' && c <= 'F') {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/image_upper_hex_digit` | yes, passes | |
| 82 | | size: unknown size accepted (`if s.Size.MemoryMiB() < 0 {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/size_empty, TestLaunchSpecValidate/size_medium and 1 more` | yes, passes | |
| 83 | | size: small reports 4096 MiB (`return 4096`) | `go test ./internal/isolatedjob -run 'TestSizeMemory' -count=1` | `isolatedjob_test.go:109: Size("small").MemoryMiB() = 4096, want 2048` | yes, passes | |
| 84 | | lifetime: zero accepted (`s.MaxLifetime < 0 ||`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/lifetime_zero` | yes, passes | |
| 85 | | lifetime: one second over the limit accepted (`s.MaxLifetime > limit+1000000000 {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/lifetime_over_the_provider_limit, TestLaunchSpecValidate/lifetime_28801_s and 1 more` | yes, passes | |
| 86 | | lifetime: limit inclusive broken (>=) (`s.MaxLifetime >= limit {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:83: Validate = isolatedjob: invalid request: lifetime 1h0m0s must be above zero and at most 1h0m0s, want nil` in `TestLaunchSpecValidate/lifetime_at_the_provider_limit, TestLaunchSpecValidate/lifetime_28800_s_at_the_hard_limit and 1 more` | yes, passes | |
| 87 | | lifetime: hard cap ignored (`limit := l.MaxLifetime`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/lifetime_28801_s_over_a_looser_provider` | yes, passes | |
| 88 | | bootstrap: empty accepted (`if false && len(s.Bootstrap) == 0 {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: invalid request` in `TestLaunchSpecValidate/bootstrap_empty, TestLaunchSpecValidate/bootstrap_zero_length` | yes, passes | |
| 89 | | bootstrap: one byte over accepted (`if len(s.Bootstrap) > l.MaxBootstrapBytes+1 {`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = <nil>, want isolatedjob: bootstrap too large` in `TestLaunchSpecValidate/bootstrap_one_byte_over` | yes, passes | |
| 90 | | bootstrap: oversize gives ErrInvalid (`ErrInvalid, len(`) | `go test ./internal/isolatedjob -run 'TestLaunchSpecValidate' -count=1` | `isolatedjob_test.go:88: Validate = isolatedjob: invalid request: bootstrap is 4097 bytes, limit 4096, want isolatedjob: bootstrap too large` in `TestLaunchSpecValidate/bootstrap_one_byte_over, TestLaunchSpecValidate/bootstrap_with_no_provider_limit` | yes, passes | |
| 91 | | state: unknown live (`...tateSuspending, StateSuspended, StateStopping, StateUnknown:`) | `go test ./internal/isolatedjob -run 'TestStateSets' -count=1` | `isolatedjob_test.go:138: State("unknown").Live() = true, want false` | yes, passes | |
| 92 | | state: unknown terminal (`case StateStopped, StateFailed, StateUnknown:`) | `go test ./internal/isolatedjob -run 'TestStateSets' -count=1` | `isolatedjob_test.go:141: State("unknown").Terminal() = true, want false` | yes, passes | |
| 93 | | state: failed not terminal (`case StateStopped:`) | `go test ./internal/isolatedjob -run 'TestStateSets' -count=1` | `isolatedjob_test.go:141: State("failed").Terminal() = false, want true` | yes, passes | |
| 94 | | audit: resolver ignored (`if false && !a.ResolverDisabled {`) | `go test ./internal/isolatedjob -run 'TestNetworkAuditOK' -count=1` | `isolatedjob_test.go:195: OK = nil, want an error naming [resolver]` in `TestNetworkAuditOK/resolver_on, TestNetworkAuditOK/everything_wrong` | yes, passes | |
| 95 | | audit: ingress ignored (`if false && !a.IngressClosed {`) | `go test ./internal/isolatedjob -run 'TestNetworkAuditOK' -count=1` | `isolatedjob_test.go:195: OK = nil, want an error naming [ingress]` in `TestNetworkAuditOK/ingress_open, TestNetworkAuditOK/everything_wrong` | yes, passes | |
| 96 | | audit: route out ignored (`if false && !a.RouteOutAbsent {`) | `go test ./internal/isolatedjob -run 'TestNetworkAuditOK' -count=1` | `isolatedjob_test.go:195: OK = nil, want an error naming [route out]` in `TestNetworkAuditOK/route_out, TestNetworkAuditOK/everything_wrong` | yes, passes | |
| 97 | | audit: extra egress ignored (`extra := missingFrom(a.EgressOnly, want)[:0]`) | `go test ./internal/isolatedjob -run 'TestNetworkAuditOK' -count=1` | `isolatedjob_test.go:195: OK = nil, want an error naming [egress]` in `TestNetworkAuditOK/extra_egress, TestNetworkAuditOK/egress_seen_none_wanted` | yes, passes | |
| 98 | | audit: missing egress ignored (`missing := missingFrom(want, a.EgressOnly)[:0]`) | `go test ./internal/isolatedjob -run 'TestNetworkAuditOK' -count=1` | `isolatedjob_test.go:195: OK = nil, want an error naming [egress]` in `TestNetworkAuditOK/missing_egress, TestNetworkAuditOK/nothing_seen` | yes, passes | |
| 99 | | clock: Mono from wall time (`return c.Wall().Sub(c.start)`) | `go test ./internal/isolatedjob -run 'TestSystemClockWallJump' -count=1` | `isolatedjob_test.go:260: step 1: Mono = -59m55s, want 10s (last 5s)` | yes, passes | |
| 100 | | clock: start loses monotonic reading (`start: now().Round(0), now:`) | `go test ./internal/isolatedjob -run 'TestSystemClock$' -count=1` | `isolatedjob_test.go:234: start = 2026-11-22 16:04:31.981554794 +0000 GMT has no monotonic reading` | yes, passes | |
| 101 | | clock: Wall derived from Mono (`return c.start.Add(c.Mono()).Round(0)`) | `go test ./internal/isolatedjob -run 'TestSystemClockWallJump' -count=1` | `isolatedjob_test.go:264: step 1: Wall = 2026-11-22 12:00:10 +0000 UTC, want 2026-11-22 11:00:05 +0000 UTC` | yes, passes | |
| 102 | | clock: Wall keeps monotonic reading (`return c.now()`) | `go test ./internal/isolatedjob -run 'TestSystemClock$' -count=1` | `isolatedjob_test.go:227: Wall = 2026-11-22 16:04:32.430137707 +0000 GMT m=+0.000216344 carries a monotonic reading` | yes, passes | |
| 103 | |
| 104 | ## Task 6 |
| 105 | |
| 106 | `isolatedjob.Fake` (an in-memory `Runner` and `NetworkAuditor`, limits from `SpikeLimits()`) and `isolatedjobtest` (`FakeClock`, `Harness`, `Contract`). Faults are one-shot and queue in order per op. `Tick` steps starting, suspending and stopping on, then the backstop stops VMs whose lifetime since launch (suspended time included while `SuspendUsesLifetime`) has reached their `MaxLifetime`. Resume of a suspended VM is accepted but the VM reports `suspended` until the next `Tick` moves it to running, as AWS keeps SUSPENDED while its /resume hook runs (controller ruling after the first commit); a second Resume in that window is accepted and changes nothing, Stop in it works as usual, and Resume of a running VM is a no-op. |
| 107 | |
| 108 | | Mutation | Command | Observed failure | Restored | |
| 109 | | --- | --- | --- | --- | |
| 110 | | idempotency keyed on Ref (`f.byAttempt[string(vm.ref)] = vm.ref`) | `go test ./internal/isolatedjob -run 'TestFakeContract/LaunchIdempotentOnAttempt' -count=1` | `contract.go:83: second Launch(contract-91c43af87640-1) = vm-0002, want vm-0001: one attempt must be one VM` | yes, passes | |
| 111 | | Tick leaves suspended time out (`if !f.limits.SuspendUsesLifetime \|\| true {`) | `go test ./internal/isolatedjob -run 'TestFakeFaults' -count=1` | `fake_test.go:212: Get(vm-0001).State = suspended, want stopping` | yes, passes | |
| 112 | | throttle applies the call (`if fl == FaultThrottle && false {`) | `go test ./internal/isolatedjob -run 'TestFakeFaults' -count=1` | `fake_test.go:116: throttled Launch = ("vm-0001", <nil>), want ("", ErrThrottled)` | yes, passes | |
| 113 | | lost reply skips the effect (`if fl == FaultLostReply { return "", ErrLostReply }` before `launchLocked`) | `go test ./internal/isolatedjob -run 'TestFakeFaults' -count=1` | `fake_test.go:134: LiveByAttempt after a lost reply = map[], want a1:1 (the launch happened)` | yes, passes | |
| 114 | | incomplete list ignored (`case FaultIncompleteList + "x":` in List) | `go test ./internal/isolatedjob -run 'TestFakeFaults' -count=1` | `fake_test.go:155: faulted List = ([{vm-0001 starting ...}], <nil>), want (nil, ErrIncomplete)` | yes, passes | |
| 115 | | unknown state ignored (`case FaultUnknownState + "x":` in Get) | `go test ./internal/isolatedjob -run 'TestFakeFaults' -count=1` | `fake_test.go:166: Get(vm-0001).State = running, want unknown` | yes, passes | |
| 116 | | age unknown ignored (`case FaultAgeUnknown + "x":` in Get) | `go test ./internal/isolatedjob -run 'TestFakeFaults' -count=1` | `fake_test.go:175: faulted Get = {... AgeKnown:true}, want AgeKnown false and still running` | yes, passes | |
| 117 | | faults not used up (`f.faults[op] = q[0:]`) | `go test ./internal/isolatedjob -run 'TestFakeFaults' -count=1` | `fake_test.go:121: Launch(a1) = isolatedjob: throttled: fake launch` (and every other row) | yes, passes | |
| 118 | | resume straight to running (`vm.state = StateRunning` in place of `vm.resuming = true` in Resume) | `go test ./internal/isolatedjob -run 'TestFakeLifecycle' -count=1` | `fake_test.go:312: Get(vm-0001).State = running, want suspended` in `TestFakeLifecycle/resume_reports_suspended_until_the_next_tick` | yes, passes | |
| 119 | |
| 120 | Fix round 1 (review r1). `Vanish(ref)` makes the fake provider forget a VM: Get, Suspend and Resume return `ErrNotFound`, Stop returns nil, List and `LiveByAttempt` leave it out, `StopsIssued` is untouched, and the client token survives (a replay returns the same Ref, a changed spec conflicts). `Calls(op)` counts calls that reached the fake provider, so a test can show a refused spec made none. `Contract` gains `Harness.ListLag`, and `OversizeBootstrapRefusedBeforeProvider` first waits (bounded by `ListLag`) for a VM it launched to show live in List, so an always-empty List fails. Line numbers in the rows above are as of `5027ce36`; the rows below are from this round. |
| 121 | |
| 122 | | Mutation | Command | Observed failure | Restored | |
| 123 | | --- | --- | --- | --- | |
| 124 | | Get sees vanished VMs (`vm, ok := f.vms[ref]` in Get) | `go test ./internal/isolatedjob -run 'TestFakeLifecycle' -count=1` | `fake_test.go:411: Get of a vanished VM = <nil>, want ErrNotFound` | yes, passes | |
| 125 | | List includes vanished VMs (`f.vms[ref]` in List) | same | `fake_test.go:415: List after vanish = ([{vm-0001 running ...} {vm-0002 running ...}], <nil>), want just vm-0002` | yes, passes | |
| 126 | | LiveByAttempt counts vanished VMs (`if vm.state.Live() {`) | same | `fake_test.go:418: LiveByAttempt after vanish = map[a1:1 a2:1], want a2:1` | yes, passes | |
| 127 | | Vanish drops the client token (`delete(f.byAttempt, vm.spec.AttemptID)`) | same | `fake_test.go:436: Launch replay after vanish = vm-0003, want vm-0001 (the client token outlives the VM)` | yes, passes | |
| 128 | | Vanish records a stop (`f.stops = append(f.stops, ref)`) | same | `fake_test.go:421: StopsIssued after vanish = [vm-0001], want none: the controller stopped nothing` | yes, passes | |
| 129 | | List always empty (`return nil, nil` in List) | `go test ./internal/isolatedjob -run 'TestFakeContract/OversizeBootstrapRefusedBeforeProvider' -count=1` | `contract.go:179: List = [] after 0s, want it to hold running VM vm-0001` | yes, passes | |
| 130 | | Launch validates after the provider call (Validate moved after `begin`) | `go test ./internal/isolatedjob -run 'TestFakeLifecycle' -count=1` | `fake_test.go:384: Launch with a bad size = isolatedjob: throttled: fake launch, want ErrInvalid` | yes, passes | |
| 131 | | lost-reply Resume skips the effect (`if fl != FaultLostReply { vm.resuming = true }`) | `go test ./internal/isolatedjob -run 'TestFakeFaults' -count=1` | `fake_test.go:173: Get(vm-0001).State = suspended, want running` | yes, passes | |
| 132 | | lost-reply Resume suppresses the error (`return finish(fl+"x", OpResume, err)`) | same | `fake_test.go:171: lost-reply Resume(vm-0001) = <nil>, want ErrLostReply and no sentinel` | yes, passes | |
| 133 | | changed spec accepted (`if false && !sameSpec(...)`) | `go test ./internal/isolatedjob -run 'TestFakeContract/ChangedSpecConflicts' -count=1` | `contract.go:104: Launch with the same attempt and a new bootstrap = ("vm-0001", <nil>), want ErrConflict` | yes, passes | |
| 134 | | Suspend ignores state (`case false && vm.state != StateRunning:`) | `go test ./internal/isolatedjob -run 'TestFakeLifecycle' -count=1` | `fake_test.go:293: Suspend while starting = <nil>, want ErrConflict` | yes, passes | |
| 135 | | Resume ignores state (`case false && vm.state != StateSuspended:`) | same | `fake_test.go:296: Resume while starting = <nil>, want ErrConflict` | yes, passes | |
| 136 | | backstop switch ignored (`if (f.backstop \|\| true) && ...`) | same | `fake_test.go:463: Get(vm-0001).State = stopping, want running` | yes, passes | |
| 137 | | Inject takes any pair (`if false && !ok {`) | same | `fake_test.go:531: Inject(OpGet, FaultIncompleteList) did not panic` | yes, passes | |
| 138 | | lost-reply Stop skips the effect (`fl != FaultLostReply &&` in Stop) | `go test ./internal/isolatedjob -run 'TestFakeFaults' -count=1` | `fake_test.go:144: Get(vm-0001).State = starting, want stopping` | yes, passes | |
| 139 | |
| 140 | ## Task 7 |
| 141 | |
| 142 | `awsjob.Runner` (Runner and NetworkAuditor over `lambdamicrovms` v1.13.0 and EC2, through the narrow `API` interface), `SNSPublisher`, and `TestProviderTypesStayInAdapter` in `isolatedjob` with the empty `guardfixture` as its target. Rows applied by a scratch script that replaced one exact string, ran the command, kept the first assertion line, wrote the original back and ran the command again. No row failed by a build error (a first try at the throttle row did, and was redone so the code still compiles). |
| 143 | |
| 144 | | Mutation | Command | Observed failure | Restored | |
| 145 | | --- | --- | --- | --- | |
| 146 | | role set (`ExecutionRoleArn: aws.String(...)` on the run request) | `go test ./internal/isolatedjob/awsjob -run '^TestRunRequestShape$' -count=1` | `runner_test.go:267: executionRoleArn = "arn:aws:iam::1:role/r", want none` | yes, passes | |
| 147 | | idle policy set (`IdlePolicy: &types.IdlePolicy{AutoResumeEnabled: aws.Bool(true)}`) | same | `runner_test.go:270: idlePolicy = {AutoResumeEnabled:0x... ...}, want none` | yes, passes | |
| 148 | | extra: client token dropped (line deleted) | same | `runner_test.go:276: clientToken = <nil>, want the attempt id "attempt-7"` | yes, passes | |
| 149 | | capabilities check dropped (`if false && !slices.Equal(out.AdditionalOsCapabilities, ...)`) | `go test ./internal/isolatedjob/awsjob -run '^TestImageVersionChecked$' -count=1` | `runner_test.go:419: Launch = <nil>, want ErrInvalid` in `capabilities_missing`, `capabilities_twice`, `capability_unknown` | yes, passes | |
| 150 | | cpu check dropped (`if false && (len(out.CpuConfigurations) != 1 \|\| ...)`) | same | `runner_test.go:419: Launch = <nil>, want ErrInvalid` in `cpu_ARM_64`, `cpu_missing`, `cpu_both` | yes, passes | |
| 151 | | memory check dropped (`if false && (len(out.Resources) != 1 \|\| ...)`) | same | `runner_test.go:419: Launch = <nil>, want ErrInvalid` in `memory_of_the_other_size`, `memory_missing`, `memory_unset`, `a_failure_is_not_cached` | yes, passes | |
| 152 | | unfamiliar state maps to failed (`return isolatedjob.StateFailed, why`) | `go test ./internal/isolatedjob/awsjob -run '^TestStateMapping$' -count=1` | `runner_test.go:524: Get(HIBERNATING).State = failed, want unknown` (also `FAILED` and `""`) | yes, passes | |
| 153 | | age from the local clock (`time.Since(*started)`) | `go test ./internal/isolatedjob/awsjob -run '^TestProviderAge$' -count=1` | `runner_test.go:593: Get = age 7782h22m36.49s known true, want age 1m30s known true` | yes, passes | |
| 154 | | partial pages returned (`return jobs, nil` on a page error) | `go test ./internal/isolatedjob/awsjob -run '^TestListAllPages$' -count=1` | `runner_test.go:883: List = <nil>, want ErrIncomplete` in `page_two_fails`, `page_one_fails` | yes, passes | |
| 155 | | extra: resume conflict always a no-op (`if true \|\| j.State == isolatedjob.StateRunning {`) | `go test ./internal/isolatedjob/awsjob -run '^TestResumeConflict$' -count=1` | `runner_test.go:754: Resume = <nil>, want ErrConflict` | yes, passes | |
| 156 | | extra: terminate not-found not swallowed (`false && errors.Is(err, isolatedjob.ErrNotFound)`) | `go test ./internal/isolatedjob/awsjob -run '^TestErrorMapping$' -count=1` | `runner_test.go:690: stop = awsjob: terminate: isolatedjob: not found: ResourceNotFoundException: gone, want nil` | yes, passes | |
| 157 | | extra: throttling not mapped (`case false && errors.As(err, &throttle), ...`) | same | `runner_test.go:703: launch = awsjob: run: ThrottlingException: slow, want isolatedjob: throttled` | yes, passes | |
| 158 | | extra: audit ignores ingress rules (`a.IngressClosed = true`) | `go test ./internal/isolatedjob/awsjob -run '^TestAuditNetwork$' -count=1` | `network_test.go:208: AuditNetwork = {... IngressClosed:true ...}, want {... IngressClosed:false ...}` | yes, passes | |
| 159 | | extra: audit ignores non-local routes (`if false && (aws.ToString(rt.GatewayId) != "local" \|\| other) {`) | same | `network_test.go:208: AuditNetwork = {... RouteOutAbsent:true ...}, want {... RouteOutAbsent:false ...}` | yes, passes | |
| 160 | | extra: audit takes a network as a host (`if err != nil {` without `IsSingleIP`) | same | `network_test.go:336: AuditNetwork = {... EgressOnly:[... 0.0.0.0:443]}, nil; want an error` | yes, passes | |
| 161 | | guard: `import _ "github.com/aws/aws-sdk-go-v2/aws"` in `guardfixture/doc.go` (`go build ./internal/isolatedjob/guardfixture` succeeds) | `go test ./internal/isolatedjob -run '^TestProviderTypesStayInAdapter$' -count=1` | `providerguard_test.go:84: packages outside amadan.net/oficina/equipo/internal/isolatedjob/awsjob depend on the AWS SDK or the adapter: amadan.net/oficina/equipo/internal/isolatedjob/guardfixture (via github.com/aws/aws-sdk-go-v2/aws)` | yes, passes | |
| 162 | | guard: `guardModule + "/internal/isolatedjob/guardfixture"` added to `providerAllowed` | same | `providerguard_test.go:35: providerAllowed holds amadan.net/oficina/equipo/internal/isolatedjob/guardfixture; only cmd/ composition points may depend on the AWS SDK or awsjob` | yes, passes | |
| 163 | | extra: guard sees test-only imports (scratch `guardfixture/leak_test.go` importing `github.com/aws/smithy-go`, then removed) | same | `providerguard_test.go:84: ... guardfixture (via github.com/aws/smithy-go)` | yes, file removed, passes | |
| 164 | |
| 165 | |
| 166 | ### Task 7 fix round 1 |
| 167 | |
| 168 | The audit now reads the pinned egress connector through lambdacore `GetNetworkConnector`. `Config.ConnectorID` must be a version-qualified ARN. The guard judges test variants by `ForTest`, and Launch refuses a non-ASCII bootstrap. Rows were applied by the same kind of scratch script. The first try at the connector-ARN row panicked (index out of range), so it was redone as below; every recorded row failed by assertion. |
| 169 | |
| 170 | | Mutation | Command | Observed failure | Restored | |
| 171 | | --- | --- | --- | --- | |
| 172 | | audit ignores the connector's subnet (`if false && !slices.Equal(c.SubnetIds, ...)`) | `go test ./internal/isolatedjob/awsjob -run '^TestAuditNetwork$' -count=1` | `network_test.go:437: AuditNetwork = {ResolverDisabled:true IngressClosed:true RouteOutAbsent:true EgressOnly:[10.0.1.10:3128 10.0.1.11:443]}, nil; want an error` in `connector_in_another_subnet`, `connector_with_an_extra_subnet` | yes, passes | |
| 173 | | audit ignores an extra group (`if false && !slices.Equal(c.SecurityGroupIds, ...)`) | same | same line, in `connector_with_another_group`, `connector_with_an_extra_group` | yes, passes | |
| 174 | | extra: audit skips the connector (`...checkConnector(ctx); false && err != nil {`) | same | same line, in all 12 connector rows | yes, passes | |
| 175 | | extra: audit ignores the connector version (`false && got != id`) | same | same line, in `connector_answers_for_another_version`, `connector_answers_unqualified` | yes, passes | |
| 176 | | extra: audit ignores service-managed Elastic IPs (`false && e != nil && ...`) | same | same line, in `connector_with_service-managed_Elastic_IPs` | yes, passes | |
| 177 | | extra: unqualified connector accepted (`if !strings.HasPrefix(c.ConnectorID, "arn:") {` in place of `qualifiedConnector`) | `go test ./internal/isolatedjob/awsjob -run '^TestNew$' -count=1` | `runner_test.go:241: New = <nil>, want ErrInvalid` in `connector_unqualified`, `connector_version_not_a_number`, `connector_in_another_region`, `connector_of_another_service` | yes, passes | |
| 178 | | ASCII check removed (`if false && b >= 0x80 {`) | `go test ./internal/isolatedjob/awsjob -run '^TestRunRequestShape$' -count=1` | `runner_test.go:367: Launch = ("vm-1", <nil>), want ErrInvalid` in `bootstrap_with_invalid_UTF-8`, `bootstrap_with_valid_non-ASCII_UTF-8` | yes, passes | |
| 179 | | guard strips _test again (`basePackage` returns `strings.TrimSuffix(path, "_test")` for any path) | `go test ./internal/isolatedjob -run '^TestProviderGuardClassifies$' -count=1` | `providerguard_test.go:185: offenders = .../internal/hostedctl (via ...) .../awsjobx (via ...) want .../internal/isolatedjob/awsjob_test (via github.com/aws/aws-sdk-go-v2/aws) ...` | yes, passes | |
| 180 | | extra: guard skips every path ending _test (`strings.HasSuffix(plainPath(p.ImportPath), "_test") \|\| ...` on the test-main skip) | same | `providerguard_test.go:182: offenders = .../awsjobx (via ...) want .../awsjob_test (via github.com/aws/aws-sdk-go-v2/aws) .../internal/hostedctl (via ...)` | yes, passes | |
| 181 | | regression: scratch ordinary package `internal/isolatedjob/awsjob_test/doc.go` importing `github.com/aws/aws-sdk-go-v2/aws` (`go build` succeeded), then removed | `go test ./internal/isolatedjob -run '^TestProviderTypesStayInAdapter$' -count=1` | `providerguard_test.go:64: packages outside .../awsjob depend on the AWS SDK or the adapter: amadan.net/oficina/equipo/internal/isolatedjob/awsjob_test (via github.com/aws/aws-sdk-go-v2/aws)` | yes, directory removed, passes | |
| 182 | |
| 183 | ### Task 7 fix round 2 |
| 184 | |
| 185 | The guard now names each go list entry by its source directory relative to the module root, not by its import path and not by `ForTest`, and skips nothing. go list gives a generated test main `p.test` and the external test `p_test [p.test]` the directory of `p`, so a real package at `p.test` or `p_test` is judged as itself. `TestProviderGuardClassifies` now holds isolatedjob's generated main and a real `internal/isolatedjob.test` package with the same import path string. |
| 186 | |
| 187 | | Mutation | Command | Observed failure | Restored | |
| 188 | | --- | --- | --- | --- | |
| 189 | | skip by path again (`if strings.HasSuffix(p.ImportPath, ".test") { continue }` before `basePackage`) | `go test ./internal/isolatedjob -run '^TestProviderGuardClassifies$' -count=1` | `providerguard_test.go:197: offenders = .../awsjob_test (via ...) .../internal/hostedctl (via ...) .../awsjobx (via ...) want ...` (the real `internal/isolatedjob.test` missing) | yes, passes | |
| 190 | | extra: judge by import path (`return plainPath(p.ImportPath)` first in `basePackage`) | same | `providerguard_test.go:195: offenders = ... .../isolatedjob/awsjob.test (via github.com/aws/aws-sdk-go-v2/aws) ... .../internal/hostedctl_test (via ...)` | yes, passes | |
| 191 | | regression: scratch real package `internal/isolatedjob.test/doc.go` importing `github.com/aws/aws-sdk-go-v2/aws` (`go build` succeeded), then removed | `go test ./internal/isolatedjob -run '^TestProviderTypesStayInAdapter$' -count=1` | `providerguard_test.go:65: packages outside .../awsjob depend on the AWS SDK or the adapter: amadan.net/oficina/equipo/internal/isolatedjob.test (via github.com/aws/aws-sdk-go-v2/aws)` | yes, directory removed, passes | |
| 192 | |
| 193 | ## Task 8 |
| 194 | |
| 195 | `internal/hostedwire`: ed25519-signed requests (headers `Equipo-Key-Id`, `Equipo-Timestamp`, `Equipo-Nonce`, `Equipo-Signature`, each exactly once, matched without regard to case) and responses (`Equipo-Signature`, bound to status, the request's nonce and the body hash), plus strict JSON wire types for every Task 15 route and `DecodeStrict`. Verify order: strict headers, key lookup (a public key shared by two IDs is refused, since the key ID is not in the signed message), skew (60 s either way, against `Verifier.Now`), body size, signature, then `Remember(r.Context(), id, nonce, now+10min)`; a held nonce is a replay and a store error denies. `DecodeStrict` reads at most `MaxBody`, needs exactly one object, and refuses unknown fields, keys not lower-case snake_case, and a key repeated in one object. RED was taken against stubs (signing real, verification and decoding naive): every test but `TestSignatureCoversEveryField`, `TestSignRequestRefusesBadInput`, `TestNewNonce` and `TestWireNames` failed by assertion; the first is shown red by the body-hash mutation below. |
| 196 | |
| 197 | | Mutation | Command | Observed failure | Restored | |
| 198 | | --- | --- | --- | --- | |
| 199 | | drop the body hash (`sha256.Sum256(nil)` in `requestMessage`) | `go test ./internal/hostedwire -run 'TestSignatureCoversEveryField' -count=1` | `sign_test.go:227: Verify after changing the body = <nil>, want hostedwire: bad signature` | yes, passes | |
| 200 | | skip `Remember` (`fresh, err := true, error(nil)`) | `go test ./internal/hostedwire -run 'TestNonceReplayRefused' -count=1` | `sign_test.go:286: replayed Verify = ("inst-1", <nil>), want ErrReplay` | yes, passes | |
| 201 | | store error treated as fresh (`fresh, err = true, nil` in the error branch) | `go test ./internal/hostedwire -run 'TestNonceStoreErrorDenies' -count=1` | `sign_test.go:305: Verify with a failing nonce store = ("inst-1", <nil>), want ErrNonceStore wrapping the store error` | yes, passes | |
| 202 | | skew bound off (`if false && (...) {`) | `go test ./internal/hostedwire -run 'TestSkewRefused' -count=1` | `sign_test.go:257: Verify with the clock -1m1s off = <nil>, want hostedwire: timestamp outside the allowed skew` | yes, passes | |
| 203 | | response not bound to the request nonce (nonce dropped from `responseMessage`) | `go test ./internal/hostedwire -run 'TestResponseBoundToRequestNonce' -count=1` | `sign_test.go:364: VerifyResponse with a changed another request's nonce = <nil>, want hostedwire: bad signature` | yes, passes | |
| 204 | | strict decode: unknown fields allowed (`DisallowUnknownFields` commented out) | `go test ./internal/hostedwire -run 'TestDecodeStrict' -count=1` | `api_test.go:45: DecodeStrict(unknown field) = <nil>, want hostedwire: body is not one strict JSON object` | yes, passes | |
| 205 | | strict decode: trailing values allowed (`values < 1`) | same | `api_test.go:45: DecodeStrict(trailing value) = <nil>, want ...` | yes, passes | |
| 206 | | strict decode: repeated key allowed | same | `api_test.go:45: DecodeStrict(duplicate field) = <nil>, want ...` | yes, passes | |
| 207 | | strict decode: key case not checked | same | `api_test.go:45: DecodeStrict(field in another case) = <nil>, want ...` | yes, passes | |
| 208 | | strict decode: top-level object not required | same | `api_test.go:45: DecodeStrict(null) = <nil>, want ...` | yes, passes | |
| 209 | | shared public key allowed (`if false && other != id ...`) | `go test ./internal/hostedwire -run 'TestSharedPublicKeyRefused' -count=1` | `sign_test.go:461: Verify as op-alias with a shared public key = ("op-alias", <nil>), want ErrSharedKey` | yes, passes | |
| 210 | | repeated header allowed (`case 1, 2:` in `single`) | `go test ./internal/hostedwire -run 'TestRequestHeadersStrict' -count=1` | `sign_test.go:444: Verify with key id twice = <nil>, want hostedwire: signature header malformed or repeated` | yes, passes | |
| 211 | | oversize body allowed in Verify | `go test ./internal/hostedwire -run 'TestOversizeBodyRefused' -count=1` | `sign_test.go:389: Verify of 1048577 signed bytes = <nil>, want ErrTooLarge` | yes, passes | |
| 212 | |
| 213 | Fix round 1 (review r1). `StopProof.ObservedAt` is controller time, a `time.Duration` since the controller's epoch, sent as integer nanoseconds in `observed_at_ns` (no wall time on the wire). `LaunchRequest.MaxLifetime()` now returns `(time.Duration, error)`: a negative `max_lifetime_ms` or one too large for a `time.Duration` is `ErrDuration`, checked before the multiplication (unchecked, 288230376155311744 and -288230376148111744 both wrapped to one hour). The signed target keeps the `?` of an empty query (`ForceQuery || RawQuery != ""`). RED: the new `TestLaunchLifetimeBounds` and the changed `TestWireNames` row did not build against the old API; the empty-query rows failed with `sign_test.go:256: Verify after the empty query added = <nil>, want ErrBadSignature` (and `removed`). Line numbers in the Task 8 rows above are as of `af8096ad`; the rows below are from this round. |
| 214 | |
| 215 | | Mutation | Command | Observed failure | Restored | |
| 216 | | --- | --- | --- | --- | |
| 217 | | proof time sent as a string (`json:"observed_at_ns,string"`) | `go test ./internal/hostedwire -run 'TestWireNames' -count=1` | `api_test.go:119: json of hostedwire.StopProof = {...,"observed_at_ns":"4611686018427387905"}, want {...,"observed_at_ns":4611686018427387905}` | yes, passes | |
| 218 | | lifetime unchecked (`if false && ms < 0 \|\| false && ms > ...`) | `go test ./internal/hostedwire -run 'TestLaunchLifetimeBounds' -count=1` | `api_test.go:157: MaxLifetime(9223372036855 ms) = (-2562047h47m16.854551616s, <nil>), want (0, ErrDuration)` | yes, passes | |
| 219 | | negative lifetime allowed (`if ms > math...`) | same | `api_test.go:157: MaxLifetime(-288230376148111744 ms) = (1h0m0s, <nil>), want (0, ErrDuration)` | yes, passes | |
| 220 | | empty query unsigned (`if r.URL.RawQuery != "" {`) | `go test ./internal/hostedwire -run 'TestSignatureCoversEveryField' -count=1` | `sign_test.go:256: Verify after the empty query added = <nil>, want ErrBadSignature` and `... empty query removed = <nil>, want ErrBadSignature` | yes, passes | |
| 221 | |
| 222 | ## Task 9 |
| 223 | |
| 224 | `internal/hostedctl` foundation: the SQLite store (schema `schema/0001_jobs.sql`, `PRAGMA user_version`, WAL, busy timeout, foreign keys, one connection, `BEGIN IMMEDIATE` transactions), controller time and the controller skeleton. Controller time: `Now() = base + (Mono() - monoAtOpen)`. Every `Tx` commit and every `Checkpoint` writes `(Now(), Wall())`; on `Open` with a checkpoint, `base = cpT + max(0, wallNow - cpWall)`, `Restarted()` is true, a wall clock behind the checkpoint adds a `clock_rollback` audit row and a startup alert that `New` must deliver, and Open writes a fresh checkpoint. A fresh database starts at T = 0 with `Restarted()` false. RED was taken against stubs (API only, T from the wall clock, no schema, no checks): all ten tests failed by assertion (for example `clock_test.go:20: Now on a fresh database = 498708h0m0s, want 0`, `store_test.go:120: Open of a database at schema 99 = nil error, want ErrSchemaNewer`, `store_test.go:184: Tx = database is locked (5) (SQLITE_BUSY)` after a panicking Tx). GREEN: `go test ./internal/hostedctl -run 'TestStore|TestAudit|TestSpecImmutable|TestRollback|TestRestart' -count=1` ok; whole package 0.6 s. |
| 225 | |
| 226 | | Mutation | Command | Observed failure | Restored | |
| 227 | | --- | --- | --- | --- | |
| 228 | | T from the wall clock (`elapsed := k.c.Wall().Sub(k.wallAtOpen)`) | `go test ./internal/hostedctl -run 'TestRollbackThenElapsedTime' -count=1` | `clock_test.go:31: Now advanced 0s after the wall clock went back 1h and Mono advanced 10m, want exactly 10m` | yes, passes | |
| 229 | | `Restarted()` false when the wall clock moved forward (`s.restarted = restarted && rollback > 0`) | `go test ./internal/hostedctl -run 'TestRestartMarksElapsedUntrusted' -count=1` | `clock_test.go:60: Restarted() after a restart with the wall clock ahead = false, want true` | yes, passes | |
| 230 | | drop the `jobs_spec_immutable` trigger | `go test ./internal/hostedctl -run 'TestSpecImmutable' -count=1` | `store_test.go:218: UPDATE jobs SET spec_json = '{"image":"b"}' ... = <nil>, want 'spec is immutable'` and `store_test.go:228: spec after refused updates = "{\"image\":\"b\"}" "bbbb", want the original` | yes, passes | |
| 231 | | extra: newer schema accepted (`if false && version > schemaVersion()`) | `go test ./internal/hostedctl -run 'TestStoreRefusesNewerSchema' -count=1` | `store_test.go:121: Open of a database at schema 99 = nil error, want ErrSchemaNewer` | yes, passes | |
| 232 | | extra: nonce replay accepted (`ON CONFLICT ... DO UPDATE SET until_unix_ns = ...`) | `go test ./internal/hostedctl -run 'TestStoreRemembersNonces' -count=1` | `store_test.go:247: Remember(inst-1, n1) = (true, <nil>), want (false, nil)` | yes, passes | |
| 233 | | extra: nil runner accepted (`case false && d.Runner == nil:`) | `go test ./internal/hostedctl -run 'TestNewRefusesNilDependency' -count=1` | `store_test.go:326: New without the runner = (&{...}, <nil>), want (nil, an error)` | yes, passes | |
| 234 | | extra: no rollback alert (`if false && rollback > 0 {`) | `go test ./internal/hostedctl -run 'TestRestartWithRollback' -count=1` | `clock_test.go:125: StartupAlerts = [], want one clock_rollback alert naming 1h0m0s at 20m` | yes, passes | |
| 235 | | extra: rollback alert sent again by a second `New` (`s.delivered = 0` after delivery) | same | `clock_test.go:146: alerts delivered after Open and two News = [{Kind:clock_rollback ...} {Kind:clock_rollback ...}], want exactly [...]` | yes, passes | |
| 236 | | extra: no checkpoint in `Tx` commits | `go test ./internal/hostedctl -run 'TestRestartKeepsCommittedTime' -count=1` | `clock_test.go:98: Now after a restart = 0s, below the 7m0s a committed row already holds` | yes, passes | |
| 237 | | extra: Open keeps the old checkpoint (`ON CONFLICT (id) DO NOTHING`) | `go test ./internal/hostedctl -run 'TestRestartMarksElapsedUntrusted' -count=1` | `clock_test.go:72: Now after a second restart with the wall clock 20m back = 15m0s, want 35m` | yes, passes | |
| 238 | |
| 239 | Fix round 1 (review r1, rulings R10-R13). These are the changes: |
| 240 | - Jobs rows are never deleted: a `jobs_never_deleted` trigger, with `recursive_triggers` on so the implicit delete of `INSERT OR REPLACE` fires it. `resume_ops` no longer cascades. |
| 241 | - `Close` checkpoints. The `Tx` checkpoint is sampled after `fn`. The invariant is narrowed to T persisted or acted on (R10). |
| 242 | - One owner per database: `Open` takes a non-blocking `flock` on `path.lock` and fails at once with `ErrStoreInUse`. |
| 243 | - Startup alerts sit in a durable `alert_outbox`. Each detail starts with `alert <id>: `. `New` delivers each alert and marks it delivered, at least once. |
| 244 | - `nonce_pruned` keeps the latest pruned expiry. `Remember` denies with `ErrNoncePruned` when `until <= mark + 2 MaxSkew`. The margin covers a replay up to 2 MaxSkew later than the original, which still passes the skew check. |
| 245 | - Typed-nil Runner, Auditor, Alerter and Clock are refused, using reflect. |
| 246 | |
| 247 | RED came after adding only the new names (`closed`, `release`, `ErrStoreInUse` stub). Every new or extended test failed except `TestRestartKeepsCommittedTime`, which R2b turns red. Examples: |
| 248 | - `store_test.go:260: replace on the attempt ID = <nil>, want "jobs are never deleted"` |
| 249 | - `store_test.go:290: second Open while the first is open = nil error, want ErrStoreInUse` |
| 250 | - `clock_test.go:207: New after a crash = <nil> with alerts [], want ...` |
| 251 | - `store_test.go:319: replay of a pruned nonce after the wall clock went back = (true, <nil>), want (false, an error)` |
| 252 | |
| 253 | GREEN: `go test ./internal/hostedctl -count=1` ok, 0.8-1.2 s. Line numbers in the Task 9 rows above are as of `3e074674`. M7, M8 and M10 were re-run against this round's code and still fail (`clock_test.go:157`, `:109`, `:178`). |
| 254 | |
| 255 | | Mutation | Command | Observed failure | Restored | |
| 256 | | --- | --- | --- | --- | |
| 257 | | R1 `recursive_triggers(0)` | `go test ./internal/hostedctl -run '^TestJobsNeverReplaced$' -count=1` | `store_test.go:260: replace on the attempt ID = <nil>, want "jobs are never deleted"` and `store_test.go:274: after refused replaces: spec "{\"image\":\"b\"}" "bbbb", ...; want the original spec and its one done row` | yes, passes | |
| 258 | | R2a `Close` without a checkpoint | `go test ./internal/hostedctl -run '^TestRestartAfterClose$' -count=1` | `clock_test.go:130: Now after Close and a wall clock 1h back = 0s, below the 10m0s seen before Close` | yes, passes | |
| 259 | | R2b `Tx` checkpoint sampled before `fn` | `go test ./internal/hostedctl -run '^TestRestartKeepsCommittedTime$' -count=1` | `clock_test.go:109: Now after a crash and a wall clock 1h back = 0s, below the 7m0s a committed row already holds` | yes, passes | |
| 260 | | R3 no `flock` (`if err := error(nil); err != nil {`) | `go test ./internal/hostedctl -run '^TestStoreOneOwner$' -count=1` | `store_test.go:290: second Open while the first is open = nil error, want ErrStoreInUse` | yes, passes | |
| 261 | | R4a outbox reloaded only for this Open's rollback (`if rollback == 0 { pending = nil }`) | `go test ./internal/hostedctl -run '^TestRestartWithRollback$' -count=1` | `clock_test.go:207: New after a crash = <nil> with alerts [], want nil and exactly [{Kind:clock_rollback Detail:alert 2: ...}]` | yes, passes | |
| 262 | | R4b delivery not marked (`SET delivered = 0`) | same | `clock_test.go:186: StartupAlerts on the next restart = [{Kind:clock_rollback Detail:alert 1: ...}], want none` | yes, passes | |
| 263 | | R5a no pruned-through check (`if false && (...)`) | `go test ./internal/hostedctl -run '^TestStoreDeniesNonceAfterPruneAndRollback$' -count=1` | `store_test.go:319: replay of a pruned nonce after the wall clock went back = (true, <nil>), want (false, an error)` | yes, passes | |
| 264 | | R5b no skew margin (`untilNs <= through`) | same | `store_test.go:325: replay 90s after the original = (true, <nil>), want (false, ErrNoncePruned)` | yes, passes | |
| 265 | | R6 plain `== nil` for Runner, Auditor, Alerter | `go test ./internal/hostedctl -run '^TestNewRefusesNilDependency$' -count=1` | `store_test.go:438: New with typed nil runner = (&{...}, <nil>), want (nil, an error)` (and auditor, alerter) | yes, passes | |
| 266 | | R6b plain `c == nil` in `Open` | `go test ./internal/hostedctl -run '^TestStoreRefusesNilClock$' -count=1` | `store_test.go:457: Open with a typed nil clock panicked (runtime error: invalid memory address or nil pointer dereference), want an error` | yes, passes | |
| 267 | |
| 268 | Fix round 2 (review r2, findings 3 and 5). |
| 269 | |
| 270 | - **One owner per database file.** The `flock` on `path.lock` locked a name, so a symlink got a second lock. It is replaced by SQLite's own lock on the file: `locking_mode(EXCLUSIVE)` with `busy_timeout(0)`. The connection keeps the lock from Open's first write until Close, for every name of the file, symlinks and hard links included. A second Open gets SQLITE_BUSY at once, which maps to `ErrStoreInUse`. |
| 271 | - This replaces option (a), a `flock` on the database file. On BSD/macOS, and on Linux NFS, `flock` and SQLite's `fcntl` locks share one lock table, so an exclusive `flock` on the file would block SQLite's own locks. |
| 272 | - modernc runs `busy_timeout` first and the other pragmas in name order. So the connection enters WAL first and then switches to EXCLUSIVE, which SQLite allows. |
| 273 | - **Nonce checks before pruning.** |
| 274 | - A held row for `(key_id, nonce)` is a replay whatever its expiry, checked before anything is pruned. |
| 275 | - The bound is now the larger of the durable mark and the latest expiry this call is about to prune, plus 2 MaxSkew. |
| 276 | - `TestStoreRemembersNonces` changed for this: an expired but still-held nonce is now a replay. |
| 277 | |
| 278 | RED: `store_test.go:326: Open through current.db while controller.db is open = nil error, want ErrStoreInUse`; `store_test.go:354: replay with until 12:10 at 12:11 = (true, <nil>), want (false, nil)`. GREEN: `go test ./internal/hostedctl -count=1` ok, 1.2 s. |
| 279 | |
| 280 | | Mutation | Command | Observed failure | Restored | |
| 281 | | --- | --- | --- | --- | |
| 282 | | R3c `_pragma=locking_mode(NORMAL)` in the DSN | `go test ./internal/hostedctl -run '^TestStoreOneOwner' -count=1` | `store_test.go:290: second Open while the first is open = nil error, want ErrStoreInUse`; `store_test.go:326: Open through current.db while controller.db is open = nil error, want ErrStoreInUse`; `store_test.go:330: Open through linked.db ... = hostedctl: migrate: disk I/O error (522), want ErrStoreInUse` | yes, passes | |
| 283 | | R7a round-1 order (no held-row check, bound from the old mark only) | `go test ./internal/hostedctl -run '^TestStoreNonceReplayAcrossWallJump$' -count=1` | `store_test.go:354: replay with until 12:10 at 12:11 = (true, <nil>), want (false, nil): a held row is a replay whatever its expiry` | yes, passes | |
| 284 | | R7b no held-row check | same | `store_test.go:354: replay with until 12:10 at 12:11 = (false, hostedctl: nonce window already pruned ...), want (false, nil)` | yes, passes | |
| 285 | | R7c bound ignores this call's prune | same | `store_test.go:360: new nonce with until 12:10 at 12:11, pruning until 12:10 = (true, <nil>), want (false, ErrNoncePruned)` | yes, passes | |
| 286 | |
| 287 | Controller ruling R15 (review r3, finding 3: database/sql can discard the connection and open a fresh one, so the exclusive lock lapses while the Store lives on). |
| 288 | - `Open` pins one `*sql.Conn` (`db.Conn`), which takes the exclusive lock at Open's first write. Migrate, clock restore, `Tx` (and through it `Checkpoint`, `Remember`, alert marking and Close's checkpoint) all run on that Conn, one transaction at a time. |
| 289 | - When a `Tx` fails, the Store checks whether the Conn is gone: the error is `driver.ErrBadConn` or `sql.ErrConnDone`, or a ping on the Conn fails. If it is gone, the Store is marked lost for good: this and every later call returns `ErrStoreLost`, and nothing reconnects. |
| 290 | - `Close` of a lost Store skips the checkpoint and only releases. Recovery is `Close` and a fresh `Open`. |
| 291 | - `TestStoreLostConnectionFailsStore`: |
| 292 | - It discards the pinned connection (`Conn.Raw` returning `driver.ErrBadConn`, as database/sql does with a bad connection). |
| 293 | - A second Store then opens, which proves the lock lapsed, and closes, writing its checkpoint. |
| 294 | - The original Store's `Tx`, `Checkpoint` and `Remember` all return `ErrStoreLost`, and the second Store's checkpoint is unchanged. |
| 295 | - RED: with the names only and `Tx` still on the pool, the run hung, because the pinned Conn holds the pool's one slot. That is a deadlock, not an assertion; the mutation below is the assertion evidence. GREEN: `go test ./internal/hostedctl -count=1` ok. |
| 296 | |
| 297 | | Mutation | Command | Observed failure | Restored | |
| 298 | | --- | --- | --- | --- | |
| 299 | | R15 continue on a new connection (on a lost Conn: `s.conn, _ = s.db.Conn(ctx); return s.runTx(ctx, fn)`) | `go test ./internal/hostedctl -run '^TestStoreLostConnectionFailsStore$' -count=1` | `store_test.go:379: Tx on the Store whose connection was discarded = <nil>, want ErrStoreLost` | yes, passes | |
| 300 | |
| 301 | ## Task 10 |
| 302 | |
| 303 | Launch intents and replay: `internal/hostedctl/{launch.go,audit.go,states.go,launch_test.go}`, plus `Config.Egress` and the in-memory audit result on `Controller` (controller.go). No schema change. |
| 304 | |
| 305 | - RED (stub with the names only): every new test failed on its assertion, for example `launch_test.go:201: Launch = not built`, `launch_test.go:495: Launch = (..., not built), want (zero view, hostedctl: hosted launches are disabled)`, `launch_test.go:637: Deadlines(0s, 8h0m0s) = (0s, 0s, 0s), want (8h0m0s, 7h15m0s, 7h50m0s)`. |
| 306 | - GREEN: `go test ./internal/hostedctl -run 'TestLaunch|TestConcurrentLaunch|TestCrashBetween|TestThrottle|TestDeadlines' -count=1` ok 1.2 s; whole package `go test ./internal/hostedctl -count=1` ok 3.3 s on a5050ff9; the new tests once under `-race`: ok. |
| 307 | - Mutations ran first with `-overlay` mapping Task 9's files to HEAD 94122cdc while its follow-up was mid-edit, then again with no overlay on a5050ff9 (the pinned connection): same outcomes and the same failure lines. Every command below is `go test ./internal/hostedctl -run '<test>' -count=1`; every row was restored and its test passed again. |
| 308 | |
| 309 | | Mutation | Test | Observed failure | Restored | |
| 310 | | --- | --- | --- | --- | |
| 311 | | M1 save the intent after the provider call | `^TestLaunchSavesIntentBeforeProvider$` | `launch_test.go:211: the provider was called before the launch intent was saved` | yes, passes | |
| 312 | | M2 skip the image check in Launch (`if false && !c.cfg.Images[q.Image]`) | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... State:starting VMRef:vm-0001 ...}, <nil>), want (zero view, hostedctl: image is not in the allowlist)` | yes, passes | |
| 313 | | M3 skip the Replaces check (`if false && q.Replaces != ""`) | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... State:starting VMRef:vm-0002 ...}, <nil>), want (zero view, hostedctl: replaced attempt is not proven stopped)` (3 rows) | yes, passes | |
| 314 | | M4 replay without re-checking the gates (abandon check and `creatable` both skipped) | `^TestThrottleThenRefusal$` | `launch_test.go:590: provider launches = 2, want 1: a failed gate calls nothing` (every row) | yes, passes | |
| 315 | | L1 Launch: flag gate dropped | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... State:starting ...}, <nil>), want (zero view, hostedctl: hosted launches are disabled)` | yes, passes | |
| 316 | | L2 Launch: role gate dropped | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... State:starting ...}, <nil>), want (zero view, hostedctl: this key may not do that)` (operator role and no key ID) | yes, passes | |
| 317 | | L3 Launch: audit gate dropped at the call site | `^TestLaunchRefusals$` | `launch_test.go:498: ... want (zero view, hostedctl: no passing network audit in the last 5 minutes)` (no audit, stale, failing, call fails) | yes, passes | |
| 318 | | L4 stale audit accepted (`age > AuditMaxAge && false`, shared) | `^(TestLaunchRefusals\|TestThrottleThenRefusal)$` | `launch_test.go:498: ... want (zero view, hostedctl: no passing network audit ...)` and `launch_test.go:590: provider launches = 2, want 1` | yes, passes | |
| 319 | | L4b audit age boundary `>=` | `^TestLaunchRefusals$` | `launch_test.go:493: Launch = (..., hostedctl: no passing network audit in the last 5 minutes: the last pass is 5m0s old), want it started` | yes, passes | |
| 320 | | L5 failing audit accepted (`false && !s.passed`, shared) | `^(TestLaunchRefusals\|TestThrottleThenRefusal)$` | `launch_test.go:498: ... want (zero view, hostedctl: no passing network audit ...)` and `launch_test.go:590: provider launches = 2, want 1` | yes, passes | |
| 321 | | L5b `!s.ran` dropped | `^TestLaunchRefusals$` | survives: equivalent, an audit that never ran also has `passed` false, so the next check refuses; only the message changes | n/a | |
| 322 | | L6 Replaces: stop proof not required | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... VMRef:vm-0002 ...}, <nil>), want (zero view, hostedctl: replaced attempt is not proven stopped)` | yes, passes | |
| 323 | | L6b Replaces: owner not checked (`if !found {`) | `^TestLaunchRefusals$` | same line, row "replaced attempt of another key" | yes, passes | |
| 324 | | L7 instance code not checked | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... State:starting ...}, <nil>), want (zero view, isolatedjob: invalid request)` (empty and non-ASCII) | yes, passes | |
| 325 | | L8 lifetime margin not checked | `^TestLaunchRefusals$` | `launch_test.go:498: Launch = ({... DeadlineIn:10m0s DrainIn:0s StopIn:0s}, <nil>), want (zero view, isolatedjob: invalid request)` | yes, passes | |
| 326 | | R1 Replay: flag gate dropped | `^TestThrottleThenRefusal$` | `launch_test.go:590: provider launches = 2, want 1: a failed gate calls nothing` | yes, passes | |
| 327 | | R2 Replay: image gate dropped | `^TestThrottleThenRefusal$` | same line, row "image removed" | yes, passes | |
| 328 | | R3 Replay: audit gate dropped at the call site (`return nil`) | `^TestThrottleThenRefusal$` | same line, rows "stale audit" and "failing audit" | yes, passes | |
| 329 | | R4 Replay: stop request ignored | `^TestThrottleThenRefusal$` | same line, row "stop requested" | yes, passes | |
| 330 | | R5 Replay: stop time ignored | `^TestThrottleThenRefusal$` | same line, row "stop time passed" | yes, passes | |
| 331 | | R5b Replay: stop time boundary `>` | `^TestThrottleThenRefusal$` | same line, row "stop time passed" (exactly at `stop_t`) | yes, passes | |
| 332 | | R6 Replay lists abandoned intents too | `^TestThrottleThenRefusal$` | survives alone: `replayOne` re-reads the row and skips anything not waiting | n/a | |
| 333 | | R6c R6 plus the re-read skip dropped | `^TestThrottleThenRefusal$` | `launch_test.go:604: Replay after abandoning = hostedctl: abandon att-1: 0 rows (<nil>)` | yes, passes | |
| 334 | | X1 a repeat of a saved intent calls the provider | `^TestConcurrentLaunchSameAttempt$` | `launch_test.go:352: Launch 0 = hostedctl: launch att-1: isolatedjob: conflict: attempt att-1 was launched with a different spec` | yes, passes | |
| 335 | | X2 replay sends a changed spec (bootstrap plus one byte) | `^TestCrashBetweenLaunchAndSave$` | `launch_test.go:401: Replay = hostedctl: launch att-1: isolatedjob: conflict: attempt att-1 was launched with a different spec` | yes, passes | |
| 336 | | X3 a throttle returned as an error | `^TestThrottleWaitsThenReplays$` | `launch_test.go:522: throttled Launch = (zero view, hostedctl: launch att-1: isolatedjob: throttled: fake launch), want a waiting view with a launch ID and no error` | yes, passes | |
| 337 | | X4 request hash ignores the key | `^TestLaunchConflictOnChangedRequest$` | `launch_test.go:312: changed Launch = ({... State:starting ...}, <nil>), want (zero view, ErrConflict)` | yes, passes | |
| 338 | |
| 339 | ### Task 10 fix round 1 |
| 340 | |
| 341 | Review r1 findings 1, 2, 4 and 5 fixed; finding 3 settled by ruling R16 (limits kept, documented in `checkRequest` as controller policy). |
| 342 | - Provider errors are classified (`providerError`): the matching isolatedjob sentinel (or context error) is kept for `errors.Is`, otherwise `ErrProviderLaunch`; the provider's text is dropped from returned errors on both paths, the throttle branch included. |
| 343 | - One `dispatch` serves Launch and Replay: it re-reads the intent in its own transaction (stop asked for, `stop_t`), then checks flag, image and audit freshness immediately before the provider call. A transient failure after transaction 1 leaves the intent waiting; Launch returns the waiting view, nil, and a `launch_deferred` audit row. |
| 344 | - The launch ID, bootstrap and spec are built inside transaction 1, only for a new attempt; validation uses a placeholder ID of the real length. |
| 345 | - The probe in `TestLaunchSavesIntentBeforeProvider` reads the store from a helper goroutine, marks the call blocked after 2 s and returns so the caller unwinds, then joins the helper. `TestConcurrentLaunchSameAttempt` now holds the first provider call until the other 19 calls have returned. |
| 346 | - New tests: `TestLaunchRechecksGatesBeforeDispatch` (transaction admission held, the audit goes stale while the launch waits; zero provider calls, intent waiting), `TestLaunchProviderTextNeverReturned` (invalid, conflict, unclassified, throttle; Launch and Replay). |
| 347 | - GREEN: the brief's command ok 1.1 s; `go test ./internal/hostedctl -count=1` ok 3.5 s (with Task 11's work in progress in the tree) and 2.6 s over HEAD; the new tests under `-race` ok. |
| 348 | - Mutations ran with `-overlay` mapping Task 11's in-flight files to HEAD and hiding its new files, so they test this code alone. Every row below was restored and passed again. Round 0 rows were re-run on the new code: all fail as before except X2, which no longer applies because Launch now also sends the decoded saved spec, so a decode change alters both calls alike; X2b replaces it. |
| 349 | |
| 350 | | Mutation | Test | Observed failure | Restored | |
| 351 | | --- | --- | --- | --- | |
| 352 | | F1 provider text kept in the returned error | `^TestLaunchProviderTextNeverReturned$` | `launch_test.go:658: Launch error "hostedctl: launch att-1: ValidationException: RunHookPayload {...\"instance_code\":\"code-SECRET-4f2a9c\"} rejected: isolatedjob: invalid request" carries the provider's text and the instance code` (also conflict, unclassified) | yes, passes | |
| 353 | | F2 no gate recheck before a Launch dispatch (`replay && gate != nil`) | `^TestLaunchRechecksGatesBeforeDispatch$` | `launch_test.go:576: provider launches = 1, want 0: the audit went stale before dispatch` | yes, passes | |
| 354 | | F4 provider call inside the intent transaction | `^TestLaunchSavesIntentBeforeProvider$` | `launch_test.go:264: provider call 0: a store read waited 2 s; a transaction is held across the provider call` | yes, passes | |
| 355 | | F4b provider call inside the dispatch transaction | `^TestLaunchSavesIntentBeforeProvider$` | same line | yes, passes | |
| 356 | | M1 provider called before the intent is saved | `^TestLaunchSavesIntentBeforeProvider$` | `launch_test.go:270: provider call 0: the provider was called before the launch intent was saved` | yes, passes | |
| 357 | | M4 replay without re-checking the gates (`!replay &&` on both checks) | `^TestThrottleThenRefusal$` | `launch_test.go:837: provider launches = 2, want 1: a failed gate calls nothing` | yes, passes | |
| 358 | | L4 audit age not checked | `^(TestLaunchRefusals\|TestThrottleThenRefusal\|TestLaunchRechecksGatesBeforeDispatch)$` | `launch_test.go:576: provider launches = 1, want 0` plus `:745` and `:837` | yes, passes | |
| 359 | | X1 a repeat of a saved intent dispatches | `^TestConcurrentLaunchSameAttempt$` | `launch_test.go:471: view 0, returned while the provider call was held = {... State:starting VMRef:vm-0001 ...}, want waiting with no ref` | yes, passes | |
| 360 | | X2b replay alone sends changed bytes | `^TestCrashBetweenLaunchAndSave$` | `launch_test.go:514: Replay = hostedctl: launch att-1: provider refused: isolatedjob: conflict` | yes, passes | |
| 361 | | M2, M3, L1-L3, L4b, L5-L8, R1-R5b, R6c, X3, X4 | as in round 0 | each fails as before (now `launch_test.go:745`, `:740`, `:837`, `:851`, `:769`, `:379`); M2, L1 and L3 now end with the intent deferred as `waiting` by the dispatch gates, L8 as `abandoned` | yes, passes | |
| 362 | |
| 363 | ## Task 11 |
| 364 | |
| 365 | Get, Stop with stop proof, unknown states and Refresh with restart reconciliation: `internal/hostedctl/{stop.go,refresh.go,stop_test.go}`. Shared files, additive only: `states.go` (JobRunning, JobSuspending, JobSuspended, JobStopping, JobStopped), `store.go` (`(*Store) OpenedAt() T`), `controller.go` (one field, `rebased rebasedSet`). No schema change. |
| 366 | |
| 367 | - RED (stub with the names only): every new test failed on its assertion, for example `stop_test.go:158: Stop of a running VM = not built, want ErrStopPending (it is only stopping)`, `stop_test.go:436: Stop by another instance = not built, want ErrForbidden`, `stop_test.go:526: Refresh = not built`. |
| 368 | - GREEN: `go test ./internal/hostedctl -run 'TestStop|TestUnknownState|TestLostStop|TestRestart' -count=1` ok 1.5 s; whole package `go test ./internal/hostedctl -count=1` ok 3.4 s on f506a22a; the new tests once under `-race`: ok. |
| 369 | - Ruling R1: `TestRestartDowntimeExceedsWallDelta` asserts the job halves only; the orphan-grace clause lands with Task 13. |
| 370 | - Every command below is `go test ./internal/hostedctl -run '<test>' -count=1`; every row was restored and its test passed again. |
| 371 | |
| 372 | | Mutation | Test | Observed failure | Restored | |
| 373 | | --- | --- | --- | --- | |
| 374 | | M1 accept `stopping` as proof (Stop) | `^TestStopProofNeedsTerminalState$` | `stop_test.go:186: Stop while the VM is stopping = <nil>, want ErrStopPending` | yes, passes | |
| 375 | | M2a accept `unknown` as proof (Stop) | `^TestUnknownStateIsNeverProof$` | `stop_test.go:238: Stop with the provider state unknown = <nil>, want ErrStateUnknown` | yes, passes | |
| 376 | | M2b accept `unknown` as proof (Refresh) | `^TestUnknownStateIsNeverProof$` | `stop_test.go:253: Refresh with an unknown state: state "stopped" (was "starting"), proof {... "state":"unknown" ...}; want it left alone` | yes, passes | |
| 377 | | M3 `max` instead of `min` when re-basing | `^TestRestartUsesProviderAge$` | `stop_test.go:531: after Refresh: launched 60000000000 deadline 7260000000000 ...; want -2340000000000 4860000000000 ...` (wall back) and `launched 16260000000000 ...; want 60000000000 ...` (wall ahead) | yes, passes | |
| 378 | | M4 `stop_t` not recomputed | `^TestRestartUsesProviderAge$` | `stop_test.go:531: after Refresh: launched -2340000000000 deadline 4860000000000 drain 2160000000000 stop 6660000000000; want ... stop 4260000000000` | yes, passes | |
| 379 | | M5 trust the wall delta for a job without age (mark settled, no stop) | `^TestRestartDowntimeExceedsWallDelta$` | `stop_test.go:592: att-1 with no age: requested {0 false} reason { false}; want stopped with elapsed_unknown` | yes, passes | |
| 380 | | M6 keep jobs whose elapsed time is unknown (`stopElapsedUnknown` returns at once) | `^TestRestartStopsWhenElapsedUnknown$` | `stop_test.go:619: att-1 after Refresh: requested {0 false} reason { false} state "starting"; want a stop for elapsed_unknown, stopping` | yes, passes | |
| 381 | | M7 creator check dropped (Stop) | `^TestStopRoles$` | `stop_test.go:437: Stop by another instance = hostedctl: stop asked for; ... VM vm-0001 is stopping, want ErrForbidden` | yes, passes | |
| 382 | | M7b creator check dropped (Get) | `^TestStopRoles$` | `stop_test.go:454: Get by another instance = <nil>, want ErrForbidden` | yes, passes | |
| 383 | | M8 role check dropped (Stop) | `^TestStopRoles$` | `stop_test.go:437: Stop by an operator key with the creator's id = ... VM vm-0001 is stopping, want ErrForbidden` | yes, passes | |
| 384 | | M9 Ref-less proof ignores unlinked live VMs | `^TestStopIntentWithoutRef$` | `stop_test.go:365: proof {"attempt_id":"att-1","vm_ref":"","state":"stopped",...} while an unlinked VM is live` | yes, passes | |
| 385 | | M10 Ref-less proof without the 2-minute wait | `^TestStopIntentWithoutRef$` | `stop_test.go:411: proof {... "observed_at_ns":119999999999} from a list started under 2 minutes after the request` | yes, passes | |
| 386 | | M10b 2-minute wait measured from the list's end | `^TestStopIntentWithoutRef$` | same line as M10 | yes, passes | |
| 387 | | M11 Ref-less proof from an incomplete list | `^TestStopIntentWithoutRef$` | `stop_test.go:381: proof {...} from an incomplete list` | yes, passes | |
| 388 | | M12 Ref-less check counts only live (not unknown) VMs | `^TestStopIntentWithoutRef$` | unreachable: the fake's List never reports `unknown` (FaultUnknownState is Get-only), so no test can tell the two checks apart; the code keeps the stricter non-terminal check | n/a | |
| 389 | | M13 re-base not once per process | `^TestRestartStopsWhenElapsedUnknown$` | `stop_test.go:633: provider stops = [vm-0001 vm-0001 vm-0002], want only vm-0001` | yes, passes | |
| 390 | | M14 pre-restart boundary `<` OpenedAt | `^TestRestartJobAtOpenTime$` | `stop_test.go:668: job launched at OpenedAt with no age: reason { false}, want elapsed_unknown` | yes, passes | |
| 391 | | M15 Refresh does not send the stop again | `^TestLostStopReplyRetries$` | `stop_test.go:306: provider stops after Refresh = [vm-0001], want a second one` | yes, passes | |
| 392 | | M16 gone VM is not proof | `^TestStopOfGoneVMSucceeds$` | `stop_test.go:331: Stop of a VM the provider no longer holds = (..., hostedctl: read VM vm-0001 of att-1 after stop: isolatedjob: not found: vm-0001), want {... State:stopped ...}` | yes, passes | |
| 393 | | M17 a VM that ended while down gets no reason `ended` | `^TestRestartFindsVMGone$` | `stop_test.go:496: att-a after Refresh: state "stopped" reason { false} requested {0 false}; want stopped, ended, no request` | yes, passes | |
| 394 | | M18 Stop does not abandon a waiting intent | `^TestStopIntentWithoutRef$` | `stop_test.go:354: after Stop: state "waiting" requested {60000000000 true} proof { false}; want abandoned at 60000000000, no proof` | yes, passes | |
| 395 | | M19 saving proof rewrites `stop_t` | `^TestStopProofNeedsTerminalState$` | `stop_test.go:211: after proof: state "stopped" reason {task done true} stop_t 0 ...; want ... times 6600000000000 7200000000000 unchanged` | yes, passes | |
| 396 | |
| 397 | ### Task 11, controller ruling R17: confirm a missing VM twice |
| 398 | |
| 399 | GetMicrovm is eventually consistent, so one not-found is no longer proof. New nullable column `jobs.notfound_since_t` in `schema/0001_jobs.sql` (nothing released). `NotFoundConfirm = 60 * time.Second` (stop.go; equals Task 13's ReapInterval). Stop and Refresh share `notFound`: a not-found proves the VM gone only when `notfound_since_t` holds an earlier not-found that came after the stop request (if any) and is at least NotFoundConfirm before this Get began; otherwise the first not-found is recorded (audit `vm_not_found`) and the result is ErrStopPending. Any live Get clears it (`mirrorState`). A terminal state is still proof at once. The Ref-less path uses List, never a Get not-found, so it is unchanged. The M16 row above is superseded by N1 to N6; line numbers in the rows above are as of 9202c3d2. |
| 400 | |
| 401 | - RED (constant only, old behaviour): `stop_test.go:332: Stop on the first not-found = <nil>, want ErrStopPending`, `stop_test.go:388: after one not-found: proof {...} notfound_since_t {0 false}; want no proof and a since time`, `stop_test.go:578: att-a after one not-found: proof {...}; want no proof yet`. |
| 402 | - GREEN: `go test ./internal/hostedctl -run 'TestStop|TestUnknownState|TestLostStop|TestRestart' -count=1` ok 3.0 s; whole package ok 3.7 s; the new tests once under `-race`: ok. |
| 403 | |
| 404 | | Mutation | Test | Observed failure | Restored | |
| 405 | | --- | --- | --- | --- | |
| 406 | | N1 accept a single not-found | `^TestStopNotFoundThenRunning$` | `stop_test.go:388: after one not-found: proof {{"attempt_id":"att-1",...,"state":"stopped",...} true} notfound_since_t {0 false}; want no proof and a since time` | yes, passes | |
| 407 | | N1b same mutation | `^(TestStopOfGoneVMSucceeds\|TestRestartFindsVMGone)$` | `stop_test.go:332: Stop on the first not-found = <nil>, want ErrStopPending` and `stop_test.go:578: att-a after one not-found: proof {...}; want no proof yet` | yes, passes | |
| 408 | | N2 a live Get does not clear `notfound_since_t` | `^TestStopNotFoundThenRunning$` | `stop_test.go:393: after a running Get: state "running" proof { false} notfound_since_t {0 true}; want running, no proof, since cleared` | yes, passes | |
| 409 | | N3 a not-found from before the stop request counts | `^TestStopNotFoundThenRunning$` | `stop_test.go:414: Stop on a not-found with the earlier one before the request = <nil>, want ErrStopPending` | yes, passes | |
| 410 | | N4 boundary `>` NotFoundConfirm | `^TestStopOfGoneVMSucceeds$` | `stop_test.go:353: Stop on a not-found 1m0s after the first = (..., ... VM vm-0001 not found once; proof needs a second not-found 1m0s later), want {... State:stopped ObservedAt:120000000000}` | yes, passes | |
| 411 | | N5 gap measured to the second Get's end | `^TestStopOfGoneVMSucceeds$` | `stop_test.go:342: Stop on a second not-found under 1m0s later = <nil>, want ErrStopPending` | yes, passes | |
| 412 | | N6 every not-found restarts the wait | `^TestStopOfGoneVMSucceeds$` | `stop_test.go:345: notfound_since_t moved to 119999999999 on a second not-found, want 60000000000 kept` | yes, passes | |
| 413 | |
| 414 | ### Task 11 fix round 1 (review r1, rulings R18 to R20) |
| 415 | |
| 416 | Changes: `attemptlock.go` (new: `func (c *Controller) lockAttempt(id string) func()`, reference-counted per-attempt mutexes; Controller field `attempts`). The lock is held by Launch's and Replay's `dispatch` (launch.go, one line), by Stop after its refusals, by Refresh's per-job reconcile and re-base, and by each Ref-less proof write; never taken inside a store transaction. Refresh saves a live state (clearing `notfound_since_t`) before any restart handling. New nullable `jobs.last_dispatch_t` (schema/0001_jobs.sql), written by `markDispatch` in its own transaction right before every provider Launch call (launch.go, three lines). Ref-less proof needs a complete List begun ReflessProofDelay after max(stop request, last dispatch, OpenedAt); a not-found pair counts only when the first is after OpenedAt (strictly) after a restart. R20: a pre-restart job whose Get fails is retried; on the RestartGetTries (3rd) failed pass in a row it is stopped as elapsed_unknown (stop request saved first), the Get error still returned. Finding 8 (stop reason limit) deferred, as ruled. |
| 417 | |
| 418 | - Order note: in this round the code and the new tests were written together; each test's guard is shown by a mutation that removes the fix (rows below), not by a separate RED run. |
| 419 | - Task 12's uncommitted files (pause.go, pause_test.go, resume.go, resume_test.go) did not compile while this ran. Every run below used `go test -overlay` mapping them to an empty `package hostedctl` file. |
| 420 | - GREEN: `go test ./internal/hostedctl -run 'TestStop|TestUnknownState|TestLostStop|TestRestart' -count=1` ok; whole package ok 7.5 s (load average 7 to 10); the targeted tests under `-race`: ok. |
| 421 | - Corrected evidence for M10b, N5 and M12 (review finding 6): the earlier rows used different mutations (`at+1`) or no reaching test. The exact mutations now fail against tests whose wrappers move the clock during Get and List and list an unlinked VM in an unknown state (rows below); M12 is no longer unreachable. |
| 422 | |
| 423 | | Mutation | Test | Observed failure | Restored | |
| 424 | | --- | --- | --- | --- | |
| 425 | | F1 Stop without the attempt lock | `^TestStopWaitsForDispatch$` | `refresh_test.go:167: Stop returned (... att-1 has no VM ref yet ...) while the launch call was in flight; it must wait for the answer` (both subtests) | yes, passes | |
| 426 | | F2 dispatch without the attempt lock | `^TestStopWaitsForDispatch$` | same line, both subtests | yes, passes | |
| 427 | | F3a Refresh reconcile without the attempt lock | `^TestRestartOverlappingRefresh$` | `refresh_test.go:426: after two overlapping passes: re-based true, stopped true; want exactly one` | yes, passes | |
| 428 | | F3b same mutation | `^TestStopNotFoundRacesLiveRead$` | `refresh_test.go:349: after a not-found and a live read: state "running" notfound_since_t {0 true}; want running and no not-found held` | yes, passes | |
| 429 | | F4 live state saved after the restart handling (the old order) | `^TestStopNotFoundClearedBeforeRestartStop$` | `refresh_test.go:387: notfound_since_t 2000000000 kept after a live read` | yes, passes | |
| 430 | | F5 a pre-open not-found counts | `^TestRestartWallJump$` | `refresh_test.go:500: Stop on a not-found after the wall jump = <nil>, want ErrStopPending: the first one is from before Open` and `refresh_test.go:529` | yes, passes | |
| 431 | | F5b pre-open boundary `>=` OpenedAt | `^TestRestartWallJump$` | `refresh_test.go:529: Stop on a not-found paired with one saved at OpenedAt = <nil>, want ErrStopPending` | yes, passes | |
| 432 | | F6 Ref-less wait ignores OpenedAt | `^TestRestartWallJump$` | `refresh_test.go:544: proof {"attempt_id":"att-1","vm_ref":"","state":"stopped","observed_at_ns":601000000000} 1 s after a restart` | yes, passes | |
| 433 | | F7 Ref-less wait ignores the last dispatch | `^TestStopIntentWithoutRefFences$` | `refresh_test.go:254: proof {...} from a list begun 1m30s after the last dispatch` | yes, passes | |
| 434 | | F8 no dispatch mark | `^(TestStopWaitsForDispatch\|TestStopIntentWithoutRefFences)$` | `refresh_test.go:154: last_dispatch_t during the provider call = {0 false}, want 0` | yes, passes | |
| 435 | | F9 stop after the first failed Get | `^TestRestartRetriesFailedGet$` | `refresh_test.go:465: pass 1: stopped after 1 failed reads, want 3 first` | yes, passes | |
| 436 | | F10 never stop on failed Gets | `^TestRestartRetriesFailedGet$` | `refresh_test.go:469: pass 3: requested {0 false} reason { false}; want a stop for elapsed_unknown` | yes, passes | |
| 437 | | M10b exact: `at` for `start` in the Ref-less wait | `^TestStopIntentWithoutRefFences$` | `refresh_test.go:271: proof {... "observed_at_ns":130000000000} from a list begun 1m40s after the request` | yes, passes | |
| 438 | | N5 exact: `at` for `before` in the not-found gap | `^TestStopNotFoundSlowGet$` | `refresh_test.go:319: Stop on a not-found Get begun 55s after the first ended = <nil>, want ErrStopPending` | yes, passes | |
| 439 | | M12 exact: Ref-less check counts only `Live()` VMs | `^TestStopIntentWithoutRefFences$` | `refresh_test.go:289: proof {...} while the list shows an unlinked VM in an unknown state` | yes, passes | |
| 440 | | TX1 Stop's provider stop inside a transaction | `^TestStopRecordsRequestBeforeProvider$` | `stop_test.go:220: provider stop (call 0): a store read waited 2 s; a transaction is held across the provider call` | yes, passes | |
| 441 | | TX2 Stop's provider get inside a transaction | `^TestStopRecordsRequestBeforeProvider$` | `stop_test.go:220: provider get (call 1): a store read waited 2 s; ...` | yes, passes | |
| 442 | | TX3 Refresh's get inside a transaction | `^TestStopRecordsRequestBeforeProvider$` | `stop_test.go:252: provider get (call 2): a store read waited 2 s; ...` | yes, passes | |
| 443 | | TX4 Refresh's list inside a transaction | `^TestStopRecordsRequestBeforeProvider$` | `stop_test.go:252: provider list (call 3): a store read waited 2 s; ...` | yes, passes | |
| 444 | | N1, M1, M5 rechecked | `^TestStopNotFoundThenRunning$`, `^TestStopProofNeedsTerminalState$`, `^TestRestartDowntimeExceedsWallDelta$` | `stop_test.go:473: after one not-found: proof {...}; want no proof and a since time`; `stop_test.go:272: Stop while the VM is stopping = <nil>, want ErrStopPending`; `stop_test.go:778: att-1 with no age: requested {0 false} ...` | yes, passes | |
| 445 | |
| 446 | ### Task 11 fix round 2 (review r2 finding 4, ruling R21, test budget) |
| 447 | |
| 448 | Changes: Refresh sends a pending stop again on every pass, whatever the restart state: on a failed Get when `stop_requested_t` is set (unless the third failed pass runs the elapsed_unknown stop itself), and on any read that is not `stopping` (live or unknown); shared helper `resendStop`. `ProviderLaunchTimeout = 60 * time.Second` (refresh.go): `dispatch` (launch.go) calls the provider Launch with `context.WithTimeout(ctx, ProviderLaunchTimeout)`, so the caller's own shorter deadline still holds. Tests: the sleeps in the concurrency tests are replaced by explicit synchronisation. `gatedGet` holds call 1 until released, and `attemptLocks.waiting` (a hook, nil in production) reports when a caller has to wait for an attempt lock. Timeouts remain only as 5 s watchdogs a healthy run never reaches. Every Task 11 test now calls `t.Parallel()`. |
| 449 | |
| 450 | - GREEN: `go test ./internal/hostedctl -run 'TestStop|TestUnknownState|TestLostStop|TestRestart|TestProviderLaunchTimeout' -count=1` ok; the same under `-race` ok. |
| 451 | - Budget: the Task 11 tests alone take 1.4 to 1.6 s of wall time (5.35 s summed before, run one after another). The whole package took 7.4 to 15 s with the host's load average between 10 and 23. The other tests alone (Tasks 9, 10 and 12, 42 tests, not parallel) took 11.9 to 13.1 s in the same window; the slowest were TestSuspendNeedsCurrentAck 0.94 s, TestResumePastDeadlineRefused 0.65 s, TestSuspendAndResumeRoles 0.57 s, TestResumeRetrySameOperation 0.49 s and TestConcurrentLaunchSameAttempt 0.49 s. |
| 452 | |
| 453 | | Mutation | Test | Observed failure | Restored | |
| 454 | | --- | --- | --- | --- | |
| 455 | | P1 a failed Get does not resend a pending stop | `^TestRestartRetriesPendingStop$` | `refresh_test.go:633: provider stops = [vm-0001], want the stop sent again` | yes, passes | |
| 456 | | D1 provider launch without a deadline (`WithCancel`) | `^TestProviderLaunchTimeout$` | `refresh_test.go:699: provider launch 0: deadline set true, 59m59.96706408s left; want one at most 1m0s away` | yes, passes | |
| 457 | | D2 timeout longer than the fence (3 min) | `^TestProviderLaunchTimeout$` | `refresh_test.go:668: ProviderLaunchTimeout = 3m0s, want 60s and under ReflessProofDelay 2m0s` | yes, passes | |
| 458 | | D3 deadline not derived from the caller (`context.Background()`) | `^TestProviderLaunchTimeout$` | `refresh_test.go:699: provider launch 2: deadline set true, 59.999997836s left; want one at most 5s away` | yes, passes | |
| 459 | | F1, F2 (recheck against the hook-based test) | `^TestStopWaitsForDispatch$` | `refresh_test.go:200: Stop returned (... att-1 has no VM ref yet ...) while the launch call was in flight; it must wait for the answer` (both subtests, each) | yes, passes | |
| 460 | | F3a, F3b (recheck against `overlap`) | `^TestRestartOverlappingRefresh$`, `^TestStopNotFoundRacesLiveRead$` | `refresh_test.go:468: after two overlapping passes: re-based true, stopped true; want exactly one`; `refresh_test.go:389: after a not-found and a live read: state "running" notfound_since_t {0 true}; ...` | yes, passes | |
| 461 | | F10 (recheck) | `^TestRestartRetriesFailedGet$` | `refresh_test.go:512: pass 3: requested {0 false} reason { false}; want a stop for elapsed_unknown` | yes, passes | |
| 462 | |
| 463 | ## Task 12 |
| 464 | |
| 465 | Pause generations (Drain, Quiescent, Suspend, Reopen) and prepared resume epochs (Resume) in |
| 466 | `internal/hostedctl/pause.go` and `resume.go`; tests in `pause_test.go` and `resume_test.go`. All five |
| 467 | methods take the verified key, as Stop does, for the instance-role check, and run under the attempt |
| 468 | lock (R18). Refresh's one change: refreshOne calls `mirrorLive` in place of `mirrorState`, which |
| 469 | leaves `draining`, `suspending` and `resuming` to the controller, settles only the expected moves, |
| 470 | and still clears `notfound_since_t` on every live sighting. States `JobDraining` and `JobResuming` |
| 471 | added to states.go. No schema change. |
| 472 | |
| 473 | - RED (compile-only stubs returning an error): all 13 tests fail on their first assertion, e.g. |
| 474 | `pause_test.go:91: Drain = (0, stub), want a new generation`. |
| 475 | - GREEN: `go test ./internal/hostedctl -run 'TestSuspend|TestLateAck|TestResume' -count=1` ok 3.5 s; |
| 476 | whole package ok 13.3 s at load average 5 to 7 (10.1 s with the Task 12 tests skipped); vet, |
| 477 | gofmt, staticcheck v0.7.0 clean; `make budget` (size) within budget. |
| 478 | |
| 479 | | Mutation | Test | Observed failure | Restored | |
| 480 | | --- | --- | --- | --- | |
| 481 | | M1 generations compared with `>=` | `^TestSuspendNeedsCurrentAck$` | `pause_test.go:118: Suspend(2) with current generation 1 = hostedctl: record suspend of att-1: 0 rows (<nil>), want hostedctl: pause generation is cancelled or not the current one` | yes, passes | |
| 482 | | M2 provider called before preparing | `^TestResumePreparesEpochBeforeProvider$` | `resume_test.go:161: store at the provider call: {state:suspended epoch:0 status:{String: Valid:false} prep:{Int64:0 Valid:false} err:<nil>}; want resuming at epoch 0 with op-1 pending at epoch 1` | yes, passes | |
| 483 | | M3 epoch raised on each call (a done operation re-prepared and committed again) | `^TestResumeRetrySameOperation$` | `resume_test.go:255: Resume(op-1) = (2, <nil>), want (1, nil)` | yes, passes | |
| 484 | | M4 commit without Get showing running | `^TestResumeLostReply$` | `resume_test.go:229: retry while the VM is suspended = (1, <nil>), want (0, ErrResumePending)` | yes, passes | |
| 485 | | M5 only the latest operation looked up | `^TestResumeOperationsRemembered$` | `resume_test.go:282: Resume(op-a) = (0, isolatedjob: conflict: only a suspended job can resume; att-1 is running), want (1, nil)` | yes, passes | |
| 486 | | M6 creator check dropped | `^TestSuspendAndResumeRoles$` | `pause_test.go:252: reopen_refused by another instance = <nil>, want ErrForbidden` | yes, passes | |
| 487 | | M7 no lazy cancellation | `^TestLateAckIgnored$` | `pause_test.go:150: Quiescent at 2m1s = <nil>, want ErrGenerationCancelled` | yes, passes | |
| 488 | | M8 no ErrPastDeadline check | `^TestResumePastDeadlineRefused$` | `resume_test.go:317: Resume at the stop time = hostedctl: a resume is pending; ...: VM vm-0001 is suspended, want ErrPastDeadline` | yes, passes | |
| 489 | | M9 Refresh hook bypassed (plain mirrorState) | `^TestSuspendRefreshSettles$` | `pause_test.go:276: Refresh of a draining job with a running VM left "running", not-found since {0 false}; want draining, cleared` | yes, passes | |
| 490 | | M10 hook leaves `notfound_since_t` for pause states | `^TestSuspendRefreshSettles$` | `pause_test.go:276: Refresh of a draining job with a running VM left "draining", not-found since {1 true}; want draining, cleared` | yes, passes | |
| 491 | | M11 a failed resume re-send fails Refresh | `^TestSuspendRefreshSettles$` | `pause_test.go:310: Refresh = isolatedjob: throttled: fake resume` | yes, passes | |
| 492 | |
| 493 | ### Task 12 fix round 1 (review r1) |
| 494 | |
| 495 | 1. Every live VM read by Resume clears `notfound_since_t` (finishResume, commitResume), the |
| 496 | controller state untouched, so a stale not-found never pairs with a later one into stop proof. |
| 497 | 2. Resume recovery respects the stop time. Resume's prepare fails a pending operation once the stop |
| 498 | time has come; driveResume checks the time again before the provider call and finishResume |
| 499 | before the commit; the Refresh hook fails a pending operation past the stop time (the job takes |
| 500 | the VM's state, no provider call, no commit) and skips a suspend re-send. Reopen past the stop |
| 501 | time is ErrPastDeadline. A pre-restart job whose times Refresh has not yet re-based |
| 502 | (`ageUnsettled`, refreshOne's untrusted test) gets no recovery from the hook on that pass, and |
| 503 | Resume answers ErrResumePending for it. Done operations still return their epoch. |
| 504 | 3. `writeProof` (stop.go) fails a pending resume in the transaction that saves the proof (one call |
| 505 | to `failPendingResume`), so Refresh's terminal and confirmed not-found proof, Stop's proof and |
| 506 | Ref-less proof all settle it. refresh.go is unchanged from HEAD in this round. |
| 507 | 4. Every Task 12 test runs with `t.Parallel()`. |
| 508 | |
| 509 | - GREEN: `go test ./internal/hostedctl -run 'TestSuspend|TestLateAck|TestResume' -count=1` ok 3.7 s; |
| 510 | whole package `-v` ok 3.9 s at load average 5 to 8 (slowest Task 12 test |
| 511 | TestResumePastDeadlineRefused 0.54 s); vet, gofmt, staticcheck v0.7.0 clean; `make budget` within. |
| 512 | - All of M1 to M11 rechecked against the new code: each still fails on its assertion (M8 now trips |
| 513 | at `resume_test.go:337`, where the dispatch-time recheck fails the operation instead) and passes |
| 514 | restored. |
| 515 | |
| 516 | | Mutation | Test | Observed failure | Restored | |
| 517 | | --- | --- | --- | --- | |
| 518 | | F1 Resume's live read keeps the not-found | `^TestResumeLiveReadClearsNotFound$` | `resume_test.go:457: after a live read: not-found since {0 true}, state "resuming"; want cleared, resuming` | yes, passes | |
| 519 | | F2a Refresh hook ignores the stop time | `^TestResumeRefreshPastDeadline$` | `resume_test.go:386: job "resuming" at epoch 0, ops [{op-1 pending ...}], 1 provider resumes; want "suspended" at 0, [{op-1 failed ...}], 1` | yes, passes | |
| 520 | | F2b Refresh recovers before the restart re-base | `^TestResumeRestartRebasesFirst$` | `resume_test.go:412: job "running" at epoch 1, ops [{op-1 done ... 1}], 1 provider resumes; want "resuming" at 0, [{op-1 pending ...}], 1` | yes, passes | |
| 521 | | F2c commit without the stop-time recheck | `^TestResumeDeadlineDuringProviderCall$` | `resume_test.go:431: Resume whose provider call crossed the stop time = (1, <nil>), want (0, ErrPastDeadline)` | yes, passes | |
| 522 | | F2d Resume does not wait for the re-base | `^TestResumeCrashAfterProvider$` | `resume_test.go:213: Resume before the first refresh after a restart = <nil>, want ErrResumePending` | yes, passes | |
| 523 | | F2e Reopen past the stop time | `^TestResumePastDeadlineRefused$` | `resume_test.go:368: Reopen at the stop time = <nil>, want ErrPastDeadline` | yes, passes | |
| 524 | | F2f a pending operation past the stop time left pending | `^TestResumePastDeadlineRefused$` | `resume_test.go:356: job "resuming" at epoch 0, ops [{op-1 pending ...}] ...; want ... [{op-1 failed ...}], 1` | yes, passes | |
| 525 | | F3 proof leaves a pending resume (writeProof's call removed) | `^TestResumeFailedByProof$` | all three subtests (ends on its own, gone confirmed, instance stops it): `resume_test.go:517: job "stopped" at epoch 0, ops [{op-1 pending ...}] ...; want "stopped" at 0, [{op-1 failed ...}], 1` | yes, passes | |
| 526 | |
| 527 | ## Task 13 |
| 528 | |
| 529 | The reaper pass and loop in `internal/hostedctl/reaper.go`, tests in `reaper_test.go`. `Reap(ctx) |
| 530 | (ReapReport, error)`, `Loop(ctx, every) error`, `LastReap() (ReapResult, bool)`, `ReapInterval`, |
| 531 | `OrphanGrace`, `UnknownAlertPasses = 3`, alert kinds `orphan_stopped`, `unknown_state`, |
| 532 | `audit_failed`. A pass, one at a time: checkpoint; Replay; Refresh; recorded jobs by saved Ref |
| 533 | (drain mark, deadline stop with reason `deadline`, unknown count and alert); orphans on a complete |
| 534 | List only (`unmatched_vms`, 10 min grace in controller time, expired at once for sightings before a |
| 535 | restart, then a recheck: audit if none fresh, Replay, List, re-read saved Refs, stop with reason |
| 536 | `orphan`, no proof); the network audit (one alert per failing run). Alerts are queued and delivered |
| 537 | at the end of the pass; one the Alerter refuses stays queued and its error joins the pass error. |
| 538 | |
| 539 | Shared-file edits: `schema/0001_jobs.sql` adds nullable `jobs.drain_marked_t` (rulings); |
| 540 | `controller.go` adds the `reap reapState` field; `refresh.go` adds one line in `refreshOne` after |
| 541 | the Get (`c.reap.observeGet`) so the reaper counts unknown reads without a second Get; |
| 542 | `stop_test.go` extends `TestRestartDowntimeExceedsWallDelta` with the orphan clause (R1): an orphan |
| 543 | seen just before the exit is stopped on the first pass after it. Its wall move is now 5 min (was 10 |
| 544 | min) so the controller time since the sighting stays under the grace. |
| 545 | |
| 546 | - RED (compile-only stubs): all 14 tests fail, e.g. `reaper_test.go:165: Reap = (..., stub)`, |
| 547 | `reaper_test.go:546: pass 0: audit_failed alerts [], want one`, `stop_test.go:765: Reap = (..., stub)`. |
| 548 | - GREEN: `go test ./internal/hostedctl -run 'TestReap|TestOrphanGrace|TestUnknownStateRetried|TestFailingAudit' -count=1` |
| 549 | ok 0.47 s (that pattern misses `TestIncompleteListSkipsOrphansOnly` and |
| 550 | `TestDeadlineEnforcedDuringIncompleteLists`; with them and `TestRestartDowntimeExceedsWallDelta` |
| 551 | ok 0.74 s, and ok under `-race`); whole package `-v` ok 3.25 s, 83 tests, load average 3 to 6; |
| 552 | vet, gofmt, staticcheck v0.7.0 clean; `make budget` within; dead-reference scan 0 failures. |
| 553 | - Mutations ran with `go test -overlay` over mutated copies under `$TMPDIR`; the tree was never |
| 554 | edited, so "restored" is the unmutated run passing. |
| 555 | |
| 556 | | Mutation | Test | Observed failure | Restored | |
| 557 | | --- | --- | --- | --- | |
| 558 | | M1 orphans processed from an incomplete List | `^TestIncompleteListSkipsOrphansOnly$` | `reaper_test.go:304: pass with an incomplete list: report {Skipped:false ... OrphansSeen:1 OrphansStopped:1 ...}, want orphans skipped` | yes, passes | |
| 559 | | M2 deadline stops skipped on an incomplete List | `^TestDeadlineEnforcedDuringIncompleteLists$` | `reaper_test.go:348: at the stop time: report {Skipped:true ... Stopped:0 ...} requested {0 false} reason { false}; want a deadline stop` | yes, passes | |
| 560 | | M3 recheck dropped (stop without the fresh List and table read) | `^TestReapRechecksOwnership$` | `reaper_test.go:237: pass at 10 min: report {... Replayed:1 ... OrphansSeen:2 OrphansStopped:2 ...}, want one orphan stopped and one replayed` | yes, passes | |
| 561 | | M3b whole recheck dropped (no replay, List or table read) | `^TestReapRechecksOwnership$` | `reaper_test.go:237: pass at 10 min: report {... Replayed:0 ... OrphansStopped:2 ...}, want one orphan stopped and one replayed` | yes, passes | |
| 562 | | M4 wall time for the grace | `^TestReaperUnderRollback$` | `reaper_test.go:434: at 10 min of elapsed time, wall clock 2 h back: report {... OrphansSeen:1 OrphansStopped:0 ...}, want the orphan stopped` | yes, passes | |
| 563 | | M5 no restart clause in the grace | `^(TestOrphanGraceExpiresAfterRestart\|TestRestartDowntimeExceedsWallDelta)$` | `reaper_test.go:469: first pass after the restart: report {... OrphansSeen:2 OrphansStopped:0 ...}, want one orphan stopped and one replayed`; `stop_test.go:805: first reaper pass after the restart: report {... OrphansStopped:0 ...}, want the orphan stopped` | yes, passes | |
| 564 | | M6 abandoned intents' VMs not reaped (no expiry while a Ref-less job is unproven) | `^TestReapStopsAbandonedIntentVM$` | `reaper_test.go:269: at 10 min: report {... OrphansSeen:1 OrphansStopped:0 ...}, want the abandoned intent's VM stopped` | yes, passes | |
| 565 | | M7 audit_failed alerted every pass | `^TestFailingAuditBlocksLaunchAndAlertsOnce$` | `reaper_test.go:546: pass 1: audit_failed alerts [{Kind:audit_failed ...} {Kind:audit_failed ...}], want one` | yes, passes | |
| 566 | | M8 no stop re-sent on an unknown read (refreshOne) | `^TestUnknownStateRetriedAndAlerted$` | `reaper_test.go:521: pass 1: provider stops [vm-0001], want 2, all to vm-0001` | yes, passes | |
| 567 | | M9 unknown_state alerted every pass | `^TestUnknownStateRetriedAndAlerted$` | `reaper_test.go:524: pass 4: unknown_state alerts [... 4 alerts ...], want 2` | yes, passes | |
| 568 | | M10 orphans before the replay | `^TestReapReplaysIntentFirst$` | `reaper_test.go:152: report {... Replayed:1 ... OrphansSeen:1 ...}, want one replayed and no orphans` | yes, passes | |
| 569 | | M11 recheck without running a missing audit | `^TestOrphanGraceExpiresAfterRestart$` | `reaper_test.go:469: first pass after the restart: report {... Replayed:0 ... OrphansStopped:2 ...}, want one orphan stopped and one replayed` | yes, passes | |
| 570 | |
| 571 | ### Task 13 fix round 1 (review r1, rulings R22, R23) |
| 572 | |
| 573 | 1. R22: the orphan final check counts waiting (not abandoned) Ref-less intents with |
| 574 | `last_dispatch_t` set; while any exist, every expired candidate is deferred, not stopped |
| 575 | (`ReapReport.OrphansDeferred`, audit `orphan_deferred` once per candidate per run of |
| 576 | deferrals). Abandoned intents never defer. |
| 577 | 2. R23: `ownershipLock` (an RWMutex in reaper.go, field `Controller.ownership`). `dispatch` |
| 578 | (launch.go, two lines) holds it for reading from just before `markDispatch` to the settled |
| 579 | answer; `finalOrphanCheck` holds it for writing from its fresh List through the last provider |
| 580 | Stop. Order: attempt lock, then ownership; the orphan path takes no attempt lock; never inside a |
| 581 | Tx. A test-only `waiting` hook reports a dispatch that has to wait. |
| 582 | 3. Every reaper audit (the recheck's and step 6) goes through `reaperAudit`: one run of failures |
| 583 | across both, the recheck's error joins the pass error. |
| 584 | 4. New guards: a stale live List entry for a proven job; the final check's own List; an incomplete |
| 585 | final-check List; the R22 deferral; the ownership lock; audit runs across both audit points. |
| 586 | |
| 587 | - New tests: `TestReapDefersOrphansWhileIntentWaits` (8 subtests: throttled, launches off, image |
| 588 | removed, audit failing; each ended by a stop request and by the stop time), |
| 589 | `TestReapOwnershipLockHoldsClaims`, `TestReapAuditEpisodesAcrossBothAudits`, |
| 590 | `TestReapProvenJobIsNeverOrphan`, `TestReapRecheckListsAgain`, |
| 591 | `TestReapIncompleteRecheckListStopsNothing`. RED: each fails under the mutation that restores |
| 592 | the round 0 behaviour it guards (R1 to R6 below). |
| 593 | - GREEN: the brief's command ok 0.47 s; whole package `-v` ok 4.33 s, 89 tests, load average 6 to |
| 594 | 7; the new tests under `-race -count=10` ok; vet, gofmt, staticcheck v0.7.0, `make budget`, |
| 595 | dead-reference scan clean. M1 to M11 re-run against this code (M3, M3b, M6 and M11 rewritten |
| 596 | for it): all fail as below and pass unmutated. |
| 597 | |
| 598 | | Mutation | Test | Observed failure | Restored | |
| 599 | | --- | --- | --- | --- | |
| 600 | | M3 final check ignores the fresh List and table | `^TestReapRechecksOwnership$` | `reaper_test.go:238: pass at 10 min: report {... Replayed:1 ... OrphansStopped:2 ...}, want one orphan stopped and one replayed` | yes, passes | |
| 601 | | M6 abandoned intents defer too (count without the state filter) | `^(TestReapStopsAbandonedIntentVM\|TestReapDefersOrphansWhileIntentWaits)$` | `reaper_test.go:270: at 10 min: report {... OrphansStopped:0 OrphansDeferred:1 ...}, want the abandoned intent's VM stopped`; `reaper_test.go:727: pass after the intent was abandoned: ... OrphansDeferred:2 ..., want both orphans stopped` | yes, passes | |
| 602 | | M11 recheck without running a missing audit | `^TestOrphanGraceExpiresAfterRestart$` | `reaper_test.go:470: first pass after the restart: report {... Replayed:0 ... OrphansStopped:0 OrphansDeferred:2 ...}, want one orphan stopped and one replayed` | yes, passes | |
| 603 | | R1 R22 deferral dropped | `^TestReapDefersOrphansWhileIntentWaits$` | all 8 subtests: `reaper_test.go:711: pass 0 after the grace: report {... OrphansStopped:2 OrphansDeferred:0 ...}, want both orphans deferred` | yes, passes | |
| 604 | | R2 R23 write lock dropped | `^TestReapOwnershipLockHoldsClaims$` | `reaper_test.go:828: VM vm-0002 was stopped as an orphan while a job held it` (5 of 5 runs) | yes, passes (10 of 10 under `-race`) | |
| 605 | | R3 recheck audit result ignored (round 0) | `^TestReapAuditEpisodesAcrossBothAudits$` | `reaper_test.go:890: pass 1: audit_failed alerts 1, want 2` | yes, passes | |
| 606 | | R4 matched query excludes proven jobs | `^TestReapProvenJobIsNeverOrphan$` | `reaper_test.go:922: report {... OrphansSeen:1 ...}, want no orphan` | yes, passes | |
| 607 | | R5 final check reuses the first List | `^TestReapRecheckListsAgain$` | `reaper_test.go:975: report {... OrphansStopped:1 ...}, want no stop of a VM the fresh list does not show` | yes, passes | |
| 608 | | R6 incomplete final-check List used | `^TestReapIncompleteRecheckListStopsNothing$` | `reaper_test.go:993: pass with an incomplete recheck list: report {Skipped:false ... OrphansStopped:1 ...}, want skipped, no stop` | yes, passes | |
| 609 | |
| 610 | ### Task 13 fix round 2 (review r2) |
| 611 | |
| 612 | `dispatch` (launch.go) now takes the ownership read lock right after the attempt lock, before the |
| 613 | readiness transaction (stop request, stop time) and the transient gates (`creatable`), and holds it |
| 614 | to the settled answer. A dispatch that waits behind the orphan final check therefore checks every |
| 615 | gate after the wait. New test `TestReapWaitingDispatchChecksGatesAfter`: the test holds the |
| 616 | ownership write lock, a Replay's dispatch waits (`waiting` hook), then (a) controller time passes |
| 617 | `stop_t`, (b) the audit goes stale, (c) a failing audit is recorded; on release each gives no |
| 618 | provider Launch, with the intent abandoned (a, `replay_abandoned` row) or waiting (b, c); a control |
| 619 | subtest with no change launches once. |
| 620 | |
| 621 | - GREEN: the brief's command ok 0.61 s; whole package `-v` ok 4.77 s, 90 tests, at load average |
| 622 | 50 to 90; the dispatch and lock tests under `-race -count=5` ok; vet, gofmt, staticcheck v0.7.0, |
| 623 | `make budget`, dead-reference scan clean. R2 re-run against the new placement: still fails as |
| 624 | before. |
| 625 | |
| 626 | | Mutation | Test | Observed failure | Restored | |
| 627 | | --- | --- | --- | --- | |
| 628 | | G1 ownership lock taken after the checks again (before `markDispatch`) | `^TestReapWaitingDispatchChecksGatesAfter$` | subtests stop time passes, audit goes stale, audit fails: `reaper_test.go:1070: provider launches after the wait = 1, want 0` | yes, passes | |
| 629 | | R2 (re-run) R23 write lock dropped | `^TestReapOwnershipLockHoldsClaims$` | `reaper_test.go:828: VM vm-0002 was stopped as an orphan while a job held it` | yes, passes | |
| 630 | |
| 631 | ## Task 14 |
| 632 | |
| 633 | `internal/hostedctl/sim_test.go` (the driver: seeds, steps, time) and `sim_model_test.go` (the |
| 634 | provider wrapper, the snapshot and the invariants). `TestLifecycleSimulation` drives the real |
| 635 | controller over the real store and `isolatedjob.Fake` (backstop off) on `isolatedjobtest.FakeClock`, |
| 636 | through public methods and `Reap`. 200 seeds by default on up to 8 workers, 40 steps a seed; |
| 637 | `EQUIPO_SIM_SEEDS=n` runs seeds 1 to n and `EQUIPO_SIM_SEED=s` replays one. A failure prints the |
| 638 | seed, the step, the violations and the last 400 lines of the step log. I1 to I7 are checked after |
| 639 | every step and every reaper pass; I3, I5, I6 (replacement launch) and I7 (prepared before the call) |
| 640 | also at the provider call itself. No production change. |
| 641 | |
| 642 | Two test-only speed measures, without which 200 seeds took 23 s: each seed copies one store migrated |
| 643 | once per run (its clock row removed, so Open still starts fresh), and the test turns off SQLite disk |
| 644 | syncs on the store's pinned connection after each Open (`PRAGMA synchronous = OFF`; a crash here is |
| 645 | Close and Open, never a power cut). |
| 646 | |
| 647 | - RED: each mutation below, applied alone, fails within the default 200 seeds with the invariant |
| 648 | named; the unmutated run passes. Mutations were edits to the tree, each restored with |
| 649 | `git checkout -- <file>`; `git diff -- '*.go' ':!internal/hostedctl/sim*_test.go'` is empty. |
| 650 | - GREEN: `go test ./internal/hostedctl -run TestLifecycleSimulation -count=1` ok 2.49 to 3.05 s over |
| 651 | six runs at load average 4 to 8; `EQUIPO_SIM_SEEDS=5000` ok 69.6 s; whole package ok 6.1 to |
| 652 | 7.3 s; 40 seeds under `-race` ok; vet, gofmt, staticcheck v0.7.0, `make budget`, dead-reference |
| 653 | scan 0 failures. Test lines in the directory 6,756 of 8,000. |
| 654 | - I5's `>=` alone (only `currentGen`) is held by a second guard: Suspend's and Quiescent's UPDATEs |
| 655 | still filter on the named generation, so the call errors with 0 rows and no provider Suspend is |
| 656 | sent (0 of 200 seeds fail, as no invariant breaks). The I5 row applies `>=` with the UPDATEs keyed |
| 657 | on the stored generation. Under I1, 3 of 154 failing seeds first report I2 (the replayed VM's |
| 658 | reply was lost too, so it is neither saved nor any intent's); 151 report I1. |
| 659 | |
| 660 | Command for every row: `go test ./internal/hostedctl -run TestLifecycleSimulation -count=1`. Seeds |
| 661 | failing of 200 in brackets. |
| 662 | |
| 663 | | Mutation | Observed failure (first seed) | Restored | |
| 664 | | --- | --- | --- | |
| 665 | | I1 Replay with a fresh client token (`spec.AttemptID += "-r"` on replay) | `sim_test.go:82: seed 1 failed at step 15: I1: attempt a2 has 2 live VMs: [vm-0003 vm-0004]` (151) | yes, passes | |
| 666 | | I2 save the intent after the provider call (Launch calls the provider before `saveIntent`) | `seed 1 failed at step 38: I2: VM vm-0006 (attempt a4, starting) is no saved Ref, matches no stored intent and was not planted` (171) | yes, passes | |
| 667 | | I3a stop orphans on first sight (`graceOver` true) | `seed 1 failed at step 2: I3: orphan stop of vm-0001 at 9s, first seen at 9s: grace not over` (106) | yes, passes | |
| 668 | | I3b drop the recheck (stop every expired orphan, no replay, List or R22 check) | `seed 77 failed at step 26: I3: orphan stop of vm-0001, the VM of waiting intent a1` (7) | yes, passes | |
| 669 | | I4a reap at `deadline_t` | `seed 1 failed at step 18: I4: VM vm-0003 of a2 is running at 8m19s, its stop time 6m47s (allowed until 7m47s)` (139) | yes, passes | |
| 670 | | I4b wall time in `reapJob` (base plus wall time since Open) | `seed 1 failed at step 18: I4: VM vm-0003 of a2 is running at 8m19s, its stop time 6m47s (allowed until 7m47s)` (25; the wall was net 10 min back) | yes, passes | |
| 671 | | I4c skip deadline stops on an incomplete List | `seed 3 failed at step 14: I4: VM vm-0003 of a3 is running at 5m34s, its stop time 3m34s (allowed until 4m34s)` (22) | yes, passes | |
| 672 | | I5 accept `>=` generations (`currentGen`, UPDATEs on the stored generation) | `seed 17 failed at step 7: I5: provider suspend of vm-0001 (a1) for generation 2; the model's pause is &{gen:1 ... acked:true}` (11) | yes, passes | |
| 673 | | I6 treat `unknown` as terminal (refreshOne) | `seed 4 failed at step 5: I6: a1 holds proof from state "unknown"` (85) | yes, passes | |
| 674 | | I7a raise the epoch before preparing (prepare UPDATE sets `epoch = epoch + 1`) | `seed 5 failed at step 21: I7: provider resume of vm-0001 for operation op-1 prepared at epoch 1 while the job's epoch is 1` (13) | yes, passes | |
| 675 | | I7b commit on a lost reply (driveResume commits on `ErrLostReply`) | `seed 25 failed at step 21: I7: a2 operation op-1 committed with no running read of vm-0002 after its last resume call` (6) | yes, passes | |
| 676 | |
| 677 | ### Task 14 fix round 1 (review r1, ruling R24) |
| 678 | |
| 679 | 1. I4 per R24: every live fake VM (stopping included) tied to a recorded attempt by saved Ref or |
| 680 | spec attempt ID, bound max(stop_t, OpenedAt) + ReapInterval with R24's extensions (a) stopping |
| 681 | after a Stop issued within the bound then in force, (b) the current run of throttled-Stop passes |
| 682 | only, (c) OrphanGrace + ReapInterval for a VM with no saved Ref, exempt while R22 deferral |
| 683 | applies (and one interval after). Three more extensions were needed for correct controller |
| 684 | behaviour, each found by an unmutated failure and flagged for a ruling: (d) a VM with no saved |
| 685 | Ref gets an interval per pass since it appeared in which a List failed (seeds 36, 43, 121: orphans |
| 686 | first seen late behind incomplete Lists); (e) after a restart a pre-restart job gets an interval |
| 687 | per pass since the open in which its Get failed, at most RestartGetTries (seed 969: R20 delays the |
| 688 | re-base); (f) a VM claimed late is bounded no earlier than one interval after the Launch reply |
| 689 | that first carried its Ref (seeds 1688, 4498: claimed by the orphan recheck's replay, after the |
| 690 | deadline step). |
| 691 | 2. I7: running evidence is tied to the pending operation the latest provider Resume was for and is |
| 692 | dropped by any other observed phase (a Get reading another state, a Suspend or Stop). A new |
| 693 | mutation I7c (commit while preparing, no provider call) checks the reviewer's case. |
| 694 | 3. I5: at every provider Suspend the stored state, generation, `pause_quiescent`, |
| 695 | `pause_cancelled` and `pause_started_t` are checked, a named generation must equal the stored |
| 696 | one, and the simulation's drain and acknowledgement history must agree; that history is also |
| 697 | checked against the store after every step and pass. |
| 698 | 4. Skip-ahead skips only with no failing-audit window, incomplete-List window or queued List fault |
| 699 | left, so no omitted pass would have played a fault (no pass is counted twice any more). |
| 700 | 5. Six directed scenarios run first under the same invariants: lost launch, stop and resume |
| 701 | replies, each confirming the provider effect and the unresolved store state, then Close, Open |
| 702 | and New before any reconciliation; a resume throttled while the VM stays suspended (after a |
| 703 | running read before the suspend); a waiting intent's VM past its orphan grace while audits fail; |
| 704 | next-generation acknowledgement and suspend refused. A model bug found on the way: a repeated |
| 705 | Resume of a done operation closed the model's newer pause (seed 250); fixed. |
| 706 | |
| 707 | - GREEN: `go test ./internal/hostedctl -run TestLifecycleSimulation -count=1` ok 2.74 to 2.84 s |
| 708 | over five runs at load average 8; `EQUIPO_SIM_SEEDS=5000` ok 73.8 s; whole package (with Task |
| 709 | 15) ok 6.66 to 7.29 s; 40 seeds under `-race` ok; vet, gofmt, staticcheck v0.7.0, `make budget`, |
| 710 | dead-reference scan 0 failures. Test lines in the directory 7,703 of 8,000. |
| 711 | - Mutations ran in a scratch copy (`git archive HEAD` plus the sim files), never in the worktree; |
| 712 | the copy was removed. Command for every row as above. "Scenarios" names the directed scenarios |
| 713 | that fail, which they do on every run. |
| 714 | |
| 715 | | Mutation | Observed failure | Seeds (of 200) | Scenarios | Restored | |
| 716 | | --- | --- | --- | --- | --- | |
| 717 | | I1 | `seed 1 failed at step 15: I1: attempt a2 has 2 live VMs: [vm-0003 vm-0004]` | 154 | lost launch; orphan recheck (I1) | yes, passes | |
| 718 | | I2 | `seed 1 failed at step 38: I2: VM vm-0006 (attempt a4, starting) is no saved Ref, ...` | 169 | lost launch; orphan recheck (I2) | yes, passes | |
| 719 | | I3a | `seed 1 failed at step 2: I3: orphan stop of vm-0001 at 9s, first seen at 9s: grace not over` | 102 | none | yes, passes | |
| 720 | | I3b | `scenario a waiting intent's VM outlives its orphan grace failed at step 3: I3: orphan stop of vm-0001, the VM of waiting intent a1` | 6 | orphan recheck | yes, passes | |
| 721 | | I4a | `seed 1 failed at step 18: I4: VM vm-0003 of a2 is running at 8m19s, its stop time 6m47s (bound 7m47s, ...)` | 138 | lost launch | yes, passes | |
| 722 | | I4b | same line as I4a at seed 1 step 18 (wall net 10 min back) | 25 | none | yes, passes | |
| 723 | | I4c | `seed 3 failed at step 14: I4: VM vm-0003 of a3 is running at 5m34s, its stop time 3m34s (bound 4m34s, ...)` | 24 | none | yes, passes | |
| 724 | | I5 | `scenario future generations are refused failed at step 4: I5: a1 generation 1 is stored acknowledged; no acknowledgement of it came in time` | 28 | future generations | yes, passes | |
| 725 | | I5 plain `>=` only | `scenario future generations are refused failed at step 4: scenario: acknowledge the next generation: unexpected result hostedctl: record quiescent for a1: 0 rows` (earlier guard; no invariant) | 0 | future generations | yes, passes | |
| 726 | | I6 | `seed 4 failed at step 5: I6: a1 holds proof from state "unknown"` | 87 | none | yes, passes | |
| 727 | | I7a | `scenario lost resume reply, crash, reconcile failed at step 7: I7: provider resume of vm-0001 for operation op-1 prepared at epoch 1 while the job's epoch is 1` | 13 | lost resume; throttled resume | yes, passes | |
| 728 | | I7b | `scenario lost resume reply, crash, reconcile failed at step 7: I7: a1 operation op-1 committed with no running read of vm-0001 after a provider resume for it` | 6 | lost resume | yes, passes | |
| 729 | | I7c commit while preparing (Resume calls `finishResume` as running, no provider call) | `scenario throttled resume while the VM stays suspended failed at step 7: I7: a1 operation op-1 committed with no running read of vm-0001 after a provider resume for it` | 13 | lost resume; throttled resume | yes, passes | |
| 730 | |
| 731 | ### Task 14 fix round 2 (review r2, ruling R24a) |
| 732 | |
| 733 | 1. R24 (b) exact: only throttled Stops inside a reaper pass count, and the run is current only |
| 734 | through consecutive passes that each throttle a Stop for the VM (`creditLocked`); a pass with |
| 735 | none ends the run and its credit. A stop that takes effect records the credit current then. |
| 736 | 2. R24a (c) exact: `simDeferral` records the first check at which R22 deferral no longer applies; |
| 737 | the bound runs from one ReapInterval after that, plus one per later pass whose List failed (d). |
| 738 | 3. New `TestSimDeadlineCredits` checks both on the review's examples: throttled at 10m, no Stop at |
| 739 | 11m, stopped at 12m is rejected (and accepted with throttles at 10m and 11m); deferred at 30m, |
| 740 | ended at 31m with an incomplete List, stopped at 32m is accepted, still live at 33m with complete |
| 741 | Lists is rejected. |
| 742 | |
| 743 | - GREEN: `go test ./internal/hostedctl -run 'TestLifecycleSimulation|TestSimDeadlineCredits' -count=1` |
| 744 | ok 2.63 to 2.68 s over four runs at load average 6; `EQUIPO_SIM_SEEDS=5000` ok 68.5 s; whole |
| 745 | package ok 6.12, 6.26 s; vet, gofmt, staticcheck v0.7.0, `make budget`, dead-reference scan clean. |
| 746 | - Mutations in scratch copies (removed): I4a 138 seeds and the lost-launch scenario, first |
| 747 | `seed 1 failed at step 18: I4: VM vm-0003 of a2 is running at 8m19s, its stop time 6m47s (bound 7m47s, ...)`; |
| 748 | I4b 25 seeds, same first line; I4c 24 seeds, first |
| 749 | `seed 3 failed at step 14: I4: VM vm-0003 of a3 is running at 5m34s, its stop time 3m34s (bound 4m34s, ...)`. |
| 750 | Checker mutations: credit kept across a broken run gives |
| 751 | `sim_model_test.go:893: throttled at 10m, no Stop at 11m, stopped at 12m: stop at 12m0s with credit 1 accepted true, want false`; |
| 752 | the round-1 deferral rule gives |
| 753 | `sim_model_test.go:908: incomplete List at 31m, stopped by the 32m pass: live at 32m0s within bound 31m0s is false, want true`; |
| 754 | no List credit after the end gives |
| 755 | `sim_model_test.go:908: incomplete Lists at 31m and 32m, live at 33m: live at 33m0s within bound 32m0s is false, want true`. |
| 756 | All restored; the restored runs pass. |
| 757 | |
| 758 | ## Task 15 |
| 759 | |
| 760 | Controller HTTP API (`internal/hostedctl/http.go`), metrics (`metrics.go`) and the |
| 761 | `equipo-hosted-controller` command (config, main wiring of awsjob, SNS alerter). No edit to an |
| 762 | existing hostedctl file. |
| 763 | |
| 764 | - RED: `go test ./internal/hostedctl -run 'TestRoutes|...|TestMetrics' -count=1` failed to build |
| 765 | (`undefined: Metrics`, `undefined: HandlerConfig`, `e.c.Handler undefined`, `undefined: apiErrors`, |
| 766 | `undefined: lookupError`). The command's tests were written with its code, not before; each guard |
| 767 | there is shown by the mutations below. First green run: `TestMetricsCountJobsByState` failed on |
| 768 | its own matcher (a HELP line matched the sample name), fixed in the test. |
| 769 | - GREEN: `go test ./internal/hostedctl ./cmd/equipo-hosted-controller -run 'TestRoutes|TestInstanceKey|TestUnknownFields|TestResponsesSigned|TestConfig|TestDisabled|TestMetrics' -count=1` |
| 770 | ok; new hostedctl tests 0.2 to 0.46 s each, in parallel; whole hostedctl package 8.0 s at load |
| 771 | average 17 to 19, the same 8.0 s with the new tests skipped; command package 0.01 s. |
| 772 | `make build vet` ok; `go test ./internal/isolatedjob -run TestProviderTypesStayInAdapter` ok; |
| 773 | `scripts/ci-test.py check` ok; `make budget` ok; staticcheck v0.7.0 clean on both packages; |
| 774 | dead-reference scan 0 failures. |
| 775 | |
| 776 | Each mutation was applied alone with a script, the named test run, and the file restored from a |
| 777 | saved copy; the test passes again after each. |
| 778 | |
| 779 | | Mutation | Command | Observed failure | Restored | |
| 780 | | --- | --- | --- | --- | |
| 781 | | Drop the creator check (Get: `j.actor != string(by)` removed) | `go test ./internal/hostedctl -run '^TestInstanceKeySeesOnlyItsJobs$' -count=1` | `http_test.go:287: instance B GET /v1/jobs/a1 = 200 {"attempt_id":"a1",...}, want 403` | yes, passes | |
| 782 | | Drop the handler's role check (`case key.Role != rt.role` to `case false`) | `go test ./internal/hostedctl -run '^TestRoutesEnforceRoles$' -count=1` | `http_test.go:239: operator GET /v1/jobs/a1 audit row = {Actor:op-1 ... Action:get_refused ...}, want api_refused by op-1` | yes, passes | |
| 783 | | Accept a wildcard listen (`IsUnspecified` check off) | `go test ./cmd/equipo-hosted-controller -run '^TestConfigRefusesWildcardListen$' -count=1` | `config_test.go:150: listen "0.0.0.0:8443" loaded, want a refusal` | yes, passes | |
| 784 | | Unsigned responses (`SignResponse` call removed) | `go test ./internal/hostedctl -run '^TestResponsesSigned$' -count=1` | `http_test.go:345: launch = 200 {...}, signed false; want a signed 200` | yes, passes | |
| 785 | | Lax decode (`json.Unmarshal` for `DecodeStrict`) | `go test ./internal/hostedctl -run '^TestUnknownFieldsRefused$' -count=1` | `http_test.go:311: launch with unknown field = 200 {...}, want 400 {"code":"bad_json",...}` | yes, passes | |
| 786 | | Error text in responses (message from `err.Error()`) | `go test ./internal/hostedctl -run '^TestRoutesEnforceRoles$' -count=1` | `http_test.go:232: operator GET /v1/jobs/a1 = 403 {"code":"forbidden","message":"hostedctl: this key may not do that: route get needs the instance role"}, want 403 {"code":"forbidden","message":"This key may not do that."}` | yes, passes | |
| 787 | | Enabled from any non-empty env value (`!= ""` for `== "1"`) | `go test ./cmd/equipo-hosted-controller -run '^TestConfigEnabledOnlyFromEnv$' -count=1` | `config_test.go:181: EQUIPO_HOSTED_ENABLED="true": Enabled true, want false` | yes, passes | |
| 788 | |
| 789 | ### Task 15 fix round 1 |
| 790 | |
| 791 | Review r1 findings 1 to 4 and ruling R25. Tests were written first: RED was |
| 792 | `TestResponsesSignedForHead` (`HEAD /v1/jobs/a1 = 405 "", signed false`), `TestResponsesSigned` |
| 793 | (`no API error with code "replay"`), and the command's build failure (`undefined: newAPIServer`, |
| 794 | `undefined: newMetricsServer`, `too many arguments in call to serve`). |
| 795 | |
| 796 | - R25: a replay (new code `replay`) and a nonce-store failure come after the signature verified, |
| 797 | so their refusals are signed bound to the request's nonce; missing or malformed headers, unknown |
| 798 | key, skew and bad signature stay unsigned. hostedwire unchanged. |
| 799 | - HEAD: the signature covers the empty body actually sent; the status is kept. |
| 800 | - `OPTIONS *`: `DisableGeneralOptionsHandler` on both servers; the API handler verifies it. |
| 801 | - Shutdown: the reaper has its own lifetime; on a signal the servers drain (30 s), then remaining |
| 802 | request contexts are cancelled, serve waits for every handler, then stops and joins the reaper; |
| 803 | the store closes after serve returns. |
| 804 | - GREEN: `go test ./internal/hostedctl ./cmd/equipo-hosted-controller -run 'TestRoutes|TestInstanceKey|TestUnknownFields|TestResponsesSigned|TestConfig|TestDisabled|TestMetrics|TestOptionsStar|TestShutdown' -count=1` |
| 805 | ok (0.46 s, 0.52 s); `make build vet` ok; Task 7 guard ok; `make budget` ok; staticcheck clean; |
| 806 | command package ok under `-race`. |
| 807 | |
| 808 | | Mutation | Command | Observed failure | Restored | |
| 809 | | --- | --- | --- | --- | |
| 810 | | `DisableGeneralOptionsHandler` off on the API server | `go test ./cmd/equipo-hosted-controller -run '^TestOptionsStarVerified$' -count=1` | `main_test.go:160: unsigned OPTIONS * = 200 "" (signature ""), want an unsigned 401` | yes, passes | |
| 811 | | HEAD signs the body it never sends (`body = nil` for HEAD removed) | `go test ./internal/hostedctl -run '^TestResponsesSignedForHead$' -count=1` | `http_test.go:430: HEAD /v1/jobs/a1 = 405 "", signed false; want a signed 405 with no body` | yes, passes | |
| 812 | | serve does not wait for running handlers (`active.closeAndWait()` removed) | `go test ./cmd/equipo-hosted-controller -run '^TestShutdownDrainsRequests$' -count=1` | `main_test.go:238: serve returned while a request handler was still running` | yes, passes | |
| 813 | | Verified refusals unsigned (`signedNonce` always "") | `go test ./internal/hostedctl -run '^TestResponsesSigned$' -count=1` | `http_test.go:395: replay = 401 {"code":"replay",...}, signed false; want a signed 401 {"code":"replay",...}` | yes, passes | |
| 814 | |
| 815 | ## Task 16 |
| 816 | |
| 817 | Instance-side client `internal/hostedclient` (`client.go`, `client_test.go`). New refuses unless |
| 818 | `EQUIPO_HOSTED_RUNNERS=1`, refuses a non-https or non-bare BaseURL, an empty key ID, keys of the wrong |
| 819 | length and a nil HTTP client (no default client: the deployment supplies TLS and timeout). One method |
| 820 | per instance route. Each response is verified against its own request nonce and the controller key |
| 821 | before its status or body is read; unsigned answers (including the controller's unsigned 401s) are |
| 822 | `ErrUnverified`. Signed refusals map by code and status to exported kinds (`ErrStopPending`, |
| 823 | `ErrConflict`, ..., plus `ErrReplay` for ruling R25's signed `replay` code); redirects are not |
| 824 | followed. No edit to hostedctl; the test builds the handler from hostedctl's public API. |
| 825 | |
| 826 | - RED: `go test ./internal/hostedclient -count=1` failed to build (`undefined: Client`, `undefined: |
| 827 | FlagEnv`, `undefined: New`, `undefined: Config`, `undefined: ErrGenerationCancelled`, ...). First |
| 828 | green run: `TestClientAgainstController` expected a relaunch of a1 to conflict; the controller |
| 829 | treats an identical relaunch as a repeat, so the test now relaunches with a different task. |
| 830 | - GREEN: `go test ./internal/hostedclient -count=1` ok, 0.42 to 0.68 s (go list -deps step 0.05 to |
| 831 | 0.08 s, warm cache). gofmt, go vet, staticcheck v0.7.0 clean; `scripts/ci-test.py check` ok; |
| 832 | dead-reference scan 0 failures. Also passes against the in-progress R25 handler change. |
| 833 | |
| 834 | | Mutation | Command | Observed failure | Restored | |
| 835 | | --- | --- | --- | --- | |
| 836 | | Skip response verification (`VerifyResponse` call replaced by nil) | `go test ./internal/hostedclient -run '^TestClientRefusesUnsignedResponse$' -count=1` | `client_test.go:273: unsigned: Get = {AttemptID:a1 ... VMRef:vm-1 ...}, <nil>; want nothing and ErrUnverified` | yes, passes | |
| 837 | | Nonce binding: verify against the response's own `Equipo-Nonce` header | same | `client_test.go:273: signed for another nonce: Get = {AttemptID:a1 ... VMRef:vm-1 ...}, <nil>; want nothing and ErrUnverified` | yes, passes | |
| 838 | | Flag from any non-empty value (`!= "1"` to `== ""`) | `go test ./internal/hostedclient -run '^TestClientRefusesWithoutFlag$' -count=1` | `client_test.go:370: New with EQUIPO_HOSTED_RUNNERS="0" = (client true, <nil>); want ErrRunnersOff` | yes, passes | |
| 839 | | https-only off (scheme check removed) | `go test ./internal/hostedclient -run '^TestNewRefusesBadConfig$' -count=1` | `client_test.go:410: New with plain http = (client true, <nil>); want a refusal` | yes, passes | |
| 840 | | Follow redirects (`CheckRedirect` line removed) | `go test ./internal/hostedclient -run '^TestClientRefusesUnsignedResponse$' -count=1` | `client_test.go:309: launch answered by a redirect = ... with 1 hits elsewhere, want ErrUnverified and none` | yes, passes | |
| 841 | | Map by code alone (status check dropped) | `go test ./internal/hostedclient -run '^TestSignedAnswersMapToKinds$' -count=1` | `client_test.go:345: code and status disagree: ... controller answered 409 "disabled"; want ... unexpected answer` | yes, passes | |
| 842 | | Stop proof check off | same | `client_test.go:359: Stop answered with proof {AttemptID:a9 ...} = {AttemptID:a9 ...}, <nil>; want nothing and ErrBadResponse` | yes, passes | |
| 843 | | cmd/equipo imports hostedclient (temporary `cmd/equipo/zz_mut.go`) | `go test ./internal/hostedclient -run '^TestInstanceDoesNotCallHostedClient$' -count=1` | `client_test.go:444: amadan.net/oficina/equipo/cmd/equipo depends on internal/hostedclient; ...` | yes, file deleted, passes | |
| 844 | |
| 845 | ### Task 16 fix round 1 (review r1) |
| 846 | |
| 847 | - Redirects: the client no longer calls `http.Client.Do`. It sends with one `RoundTrip` on |
| 848 | `HTTP.Transport` (`http.DefaultTransport` when nil), with `HTTP.Timeout` applied as a context |
| 849 | deadline over the whole call, body read included. A 3xx is never parsed or followed before it is |
| 850 | verified. The unverified-answer error no longer names the status. |
| 851 | - Contract: `hostedctl.ErrorCodes()` (new, read-only: every status and code pair of `apiErrors` and |
| 852 | `errInternal`). `TestClientMatchesHandlerErrorCodes` requires every handler pair to map to a typed |
| 853 | kind and the client to know no code the handler does not send. |
| 854 | - Guards: `TestSignedSuccessMustFit` has one signed 200 case per success guard. |
| 855 | - Dependency guard: `testci.GoCommand` declares cmd/equipo's source as test inputs; the `go list` runs |
| 856 | under `exec.CommandContext` (8 s) and prints its stderr on failure. |
| 857 | - Cache check, normal command `go test ./internal/hostedclient` (no -count): `ok 0.815s`, then |
| 858 | `ok (cached)`; add `cmd/equipo/zz_mut.go` importing hostedclient: `client_test.go:575: |
| 859 | amadan.net/oficina/equipo/cmd/equipo depends on internal/hostedclient; ...` FAIL; file deleted, |
| 860 | `ok 0.740s`. Control with the `testci.GoCommand` line disabled: after the same import, `ok (cached)`. |
| 861 | - `go test ./internal/hostedclient -count=1` ok 0.72 s (10 tests); `go test ./internal/hostedctl |
| 862 | -run 'TestRoutes|TestResponsesSigned' -count=1` ok; gofmt, vet, staticcheck v0.7.0 clean on both |
| 863 | packages; `ci-test.py check` ok; dead-reference scan 0 failures. |
| 864 | |
| 865 | | Mutation | Command | Observed failure | Restored | |
| 866 | | --- | --- | --- | --- | |
| 867 | | Back to `http.Client.Do` with `CheckRedirect` | `go test ./internal/hostedclient -run '^TestClientRefusesUnsignedResponse$' -count=1` | `client_test.go:333: redirect to %, signed false: Launch = hostedclient: launch: Post "https://127.0.0.1:44573/v1/jobs": failed to parse Location header "%": ... want hostedclient: the response could not be verified after 1` | yes, passes | |
| 868 | | HTTP timeout not applied | `... -run '^TestClientHonoursTimeoutAndCancel$' ...` | `client_test.go:359: Get past the HTTP timeout = hostedclient: the response could not be verified: ... after 3.0025s, want context.DeadlineExceeded within 2 s` | yes, passes | |
| 869 | | Status back in the unverified error | `... -run '^TestClientRefusesUnsignedResponse$' ...` | `client_test.go:337: unsigned redirect error "hostedclient: the response could not be verified: launch (unverified status 307): ..." holds text from the answer` | yes, passes | |
| 870 | | Handler code renamed (`network_audit` to `audit_stale`, http.go) | `... -run '^TestClientMatchesHandlerErrorCodes$' ...` | `client_test.go:417: handler refusal 503 "audit_stale" maps to ... unexpected answer ..., want a typed kind` and `client_test.go:425: client maps 503 "network_audit", which the handler does not send` | yes, passes | |
| 871 | | Handler status changed (`past_deadline` 410 to 409, http.go) | same | `client_test.go:417: handler refusal 409 "past_deadline" maps to ... unexpected answer ...` and `client_test.go:425: client maps 410 "past_deadline", which the handler does not send` | yes, passes | |
| 872 | | Client entry `network_audit` removed | same | `client_test.go:417: handler refusal 503 "network_audit" maps to ... unexpected answer ..., want a typed kind` | yes, passes | |
| 873 | | Launch attempt check off | `... -run '^TestSignedSuccessMustFit$' ...` | `client_test.go:466: launch view for another attempt: = {AttemptID:a9 ...}, <nil>; want ErrBadResponse` | yes, passes | |
| 874 | | Get attempt check off | same | `client_test.go:466: get view for another attempt: = {AttemptID:a9 ...}, <nil>; want ErrBadResponse` | yes, passes | |
| 875 | | `DecodeStrict` to `json.Unmarshal` for successes | same | `client_test.go:466: get view with an unknown field: = {AttemptID:a1 ...}, <nil>; want ErrBadResponse` | yes, passes | |
| 876 | | Stop proof: attempt half removed | same | `client_test.go:466: stop proof for another attempt: = {AttemptID:a9 ... State:stopped ...}, <nil>; want ErrBadResponse` | yes, passes | |
| 877 | | Stop proof: terminal half removed | same | `client_test.go:466: stop proof not terminal: = {AttemptID:a1 ... State:running ...}, <nil>; want ErrBadResponse` | yes, passes | |
| 878 | | Drain generation >= 1 off | same | `client_test.go:466: drain generation 0: = 0, <nil>; want ErrBadResponse` | yes, passes | |
| 879 | | Generation echo off (`generationCall`) | same | `client_test.go:466: quiescent for another generation: = <nil>, <nil>; want ErrBadResponse` (and suspend, reopen) | yes, passes | |
| 880 | | Resume epoch >= 1 off | same | `client_test.go:466: resume epoch 0: = 0, <nil>; want ErrBadResponse` | yes, passes | |
| 881 | | Skip response verification (rerun) | `... -run '^TestClientRefusesUnsignedResponse$' ...` | `client_test.go:274: unsigned: Get = {AttemptID:a1 ... VMRef:vm-1 ...}, <nil>; want nothing and ErrUnverified` | yes, passes | |
| 882 | |
| 883 | The round 0 rows above give line numbers from before this round. |
| 884 | |
| 885 | ### Task 16 fix round 2 (review r2) |
| 886 | |
| 887 | - Transport and body-read errors go through `transportError`: `ErrTransport` plus the route and |
| 888 | step ("sending" or "reading the body"). `context.Canceled` and `context.DeadlineExceeded` stay |
| 889 | matchable with errors.Is, and a `net.Error` timeout keeps the fixed words "network timeout". The |
| 890 | original error's text, which can quote server bytes, is dropped. `Config.HTTP` now documents that |
| 891 | the transport must honour request contexts (Request.Cancel or CancelRequest-only transports are |
| 892 | not supported). |
| 893 | - `TestTransportErrorsHoldNoServerBytes`: a TLS server hijacks the connection and sends a malformed |
| 894 | status line, a header with no colon, or a chunked body with a malformed trailer. Each gives |
| 895 | ErrTransport, not ErrUnverified, and none of the sent bytes. |
| 896 | - `go test ./internal/hostedclient -count=1` ok 0.95 s (11 tests); gofmt, vet, staticcheck v0.7.0 |
| 897 | clean; dead-reference scan 0 failures. |
| 898 | |
| 899 | | Mutation | Command | Observed failure | Restored | |
| 900 | | --- | --- | --- | --- | |
| 901 | | Wrap the raw error again (`%w` of err in `transportError`) | `go test ./internal/hostedclient -run '^TestTransportErrorsHoldNoServerBytes$' -count=1` | `client_test.go:365: malformed status: error "... get: sending: net/http: HTTP/1.x transport connection broken: malformed HTTP status code \"EVIL\"" holds bytes the server sent`, the same for the header (`missing colon: \"EVIL-HEADER-NO-COLON\"`) and the trailer (`reading the body: malformed MIME header: missing colon: \"EVIL-TRAILER\"`) | yes, passes | |
| 902 | | Deadline classification dropped | `go test ./internal/hostedclient -run '^TestClientHonoursTimeoutAndCancel$' -count=1` | `client_test.go:387: Get past the HTTP timeout = hostedclient: the exchange with the controller failed: get: sending: network timeout after 100.7ms, want context.DeadlineExceeded within 2 s` | yes, passes | |
| 903 | |
| 904 | ## Final fix wave |
| 905 | |
| 906 | Findings from the final whole-branch review (final-A, B1, B2, C), fixed under rulings R26 to R31. |
| 907 | |
| 908 | ### A1 + A2: provider namespace binding and launch fingerprint (R28, R29) |
| 909 | |
| 910 | - `provider_binding` (one row, never updated) holds the namespace; `New` needs |
| 911 | `Config.ProviderNamespace` and `Config.ProviderFingerprint`, binds a fresh database, and returns |
| 912 | `ErrProviderMismatch` for another namespace before anything reads the provider. Main resolves |
| 913 | `aws:ACCOUNT:REGION` with a bounded STS GetCallerIdentity. |
| 914 | - Each intent saves `provider_fingerprint` (immutable with the spec). `dispatch` abandons an intent |
| 915 | whose fingerprint differs from the current one (reason `config_changed`, an AlertConfigChanged |
| 916 | alert, no provider call); the lost reply's VM is then an orphan. `awsjob.Config.Fingerprint` is |
| 917 | region, connector, image ARN and the size's version. |
| 918 | |
| 919 | | Mutation | Command | Observed failure | Restored | |
| 920 | | --- | --- | --- | --- | |
| 921 | | Accept a mismatched binding (`bound != ns && false`) | `go test ./internal/hostedctl -run 'TestProviderNamespaceBound$' -count=1` | `store_test.go:605: New for another namespace = (&{...test:account-2:region-1...}, <nil>), want ErrProviderMismatch` | yes, passes | |
| 922 | | Skip the fingerprint check in `dispatch` | `go test ./internal/hostedctl -run 'TestReplayRefusesChangedProviderConfig$' -count=1` | `launch_test.go:555: provider launches = 2, want only the lost one` | yes, passes | |
| 923 | | Leave the version out of `awsjob.Config.Fingerprint` | `go test ./internal/isolatedjob/awsjob -run 'TestFingerprint$' -count=1` | `runner_test.go:252: small and large share a fingerprint, though their versions differ` | yes, passes | |
| 924 | |
| 925 | ### B1: gates rechecked after the dispatch marker commits |
| 926 | |
| 927 | - After `markDispatch` commits, `dispatch` reads controller time once more, in memory: at or past |
| 928 | the intent's stop time it abandons the intent (`abandonDue`); a failed `creatable` (launches off, |
| 929 | image dropped, audit failed or stale) leaves it waiting; only then the provider call. |
| 930 | - `TestDispatchRechecksGatesAfterMarker`: a test hook (`beforeMark`) holds the store so the marker's |
| 931 | transaction queues; the test invalidates one gate (stop time passes, audit fails, audit goes |
| 932 | stale), then releases the store. No provider launch in any case; the marker is recorded. |
| 933 | |
| 934 | | Mutation | Command | Observed failure | Restored | |
| 935 | | --- | --- | --- | --- | |
| 936 | | Drop both post-marker checks | `go test ./internal/hostedctl -run 'TestDispatchRechecksGatesAfterMarker$' -count=1` | `launch_test.go:672: provider launches = 1, want 0` in all three subtests | yes, passes | |
| 937 | | Drop only the stop-time check | same | `launch_test.go:675: att-1 = {state:waiting ... lastDispatch:{Int64:7200000000000 Valid:true} ... stop:6600000000000}, want abandoned with its dispatch marker` | yes, passes | |
| 938 | |
| 939 | ### B2-1, B2-3, B2-4: deadline stops before replay, Reopen after reconciliation, pauses across a restart |
| 940 | |
| 941 | - B2-1 (R26): `reapOverdue` runs right after the pass's checkpoint and sends the deadline stop |
| 942 | (`reapJob`) for every Ref'd, unproven, unrequested job at or past its stop time, before Replay. |
| 943 | Step 4 repeats and finds the stop already asked for. |
| 944 | - B2-3: `Reopen` refuses with `isolatedjob.ErrConflict` while `ageUnsettled`, then judges the |
| 945 | re-based stop time. |
| 946 | - B2-4: `expire` (now a method) also cancels an unacknowledged generation whose Drain is at or |
| 947 | before `OpenedAt` after a restart. The simulation's model now counts an acknowledgement of a |
| 948 | generation drained before the last restart as never in time, so I5 would catch a controller that |
| 949 | accepted one. |
| 950 | |
| 951 | | Mutation | Command | Observed failure | Restored | |
| 952 | | --- | --- | --- | --- | |
| 953 | | Drop `reapOverdue` from the pass | `go test ./internal/hostedctl -run 'TestDeadlineStopBeforeSlowReplay$' -count=1` | `reaper_test.go:393: provider stops while the replay's launch call hung = [], want att-1's vm-0001` | yes, passes | |
| 954 | | Drop the `ageUnsettled` refusal in `Reopen` | `go test ./internal/hostedctl -run 'TestReopenWaitsForRestartReconciliation$' -count=1` | `pause_test.go:236: Reopen before the first refresh = <nil>, want ErrConflict` | yes, passes | |
| 955 | | Drop the restart case in `expire` | `go test ./internal/hostedctl -run 'TestPauseAckAcrossRestartCancelled$' -count=1` | `pause_test.go:209: refresh first false: Quiescent(1) after the restart = <nil>, want ErrGenerationCancelled` | yes, passes | |
| 956 | | Same mutation, simulation | `EQUIPO_SIM_SEEDS=500 go test ./internal/hostedctl -run 'TestLifecycleSimulation' -count=1` | `sim_test.go:94: seed 12 failed at step 38: I5: a3 generation 1 is stored acknowledged; no acknowledgement of it came in time` (also seeds 50, 106) | yes, 500 seeds pass | |
| 957 | |
| 958 | ### C1: slice 1a runs with no egress (R30) |
| 959 | |
| 960 | - `awsjob.Config` accepts an empty egress set (a group with no outbound rules); the command refuses |
| 961 | a non-empty `egress` in slice 1a, so `ctl.Egress` is empty and the audit expects `EgressOnly` |
| 962 | empty. `TestAuditNetwork/no_egress_against_a_group_with_no_rules` audits a no-rule group: no |
| 963 | egress, `OK(nil)` passes, and `OK` against a non-empty set still fails. |
| 964 | |
| 965 | | Mutation | Command | Observed failure | Restored | |
| 966 | | --- | --- | --- | --- | |
| 967 | | Refuse empty egress in `awsjob.Config.check` again | `go test ./internal/isolatedjob/awsjob -run 'TestNew$\|TestAuditNetwork$' -count=1` | `runner_test.go:208: New(no egress) = isolatedjob: invalid request: awsjob config: no egress destinations, want nil` and `network_test.go:267: New(no egress) = ...` | yes, passes | |
| 968 | | Accept a non-empty egress in the command | `go test ./cmd/equipo-hosted-controller -run 'TestConfigRefusesMissingListenOrKeys$' -count=1` | `config_test.go:114: egress in slice 1a: config loaded, want a refusal` | yes, passes | |
| 969 | |
| 970 | ### C2 + B2-2: bounded provider calls, cancellable recovery calls, shutdown order (R27) |
| 971 | |
| 972 | - `New` wraps the runner and auditor (`bounded.go`): Launch gets `ProviderLaunchTimeout` (60 s, |
| 973 | moved out of `dispatch`), every other call and the network audit `ProviderCallTimeout` (30 s), |
| 974 | each derived from the caller's context. |
| 975 | - `refreshOne` passes its own context to `mirrorLive`, which uses it for the Suspend and Resume it |
| 976 | sends again and a detached copy only for store writes and audit rows. |
| 977 | - `serve` cancels the requests and the reaper together after the drain period, then joins both; |
| 978 | the caller closes the store after. |
| 979 | |
| 980 | | Mutation | Command | Observed failure | Restored | |
| 981 | | --- | --- | --- | --- | |
| 982 | | Old shutdown order (join handlers before cancelling the reaper) | `go test ./cmd/equipo-hosted-controller -run 'TestShutdownCancelsReaperWithRequests$' -count=1` | `main_test.go:281: serve did not return within 10 s of the signal` | yes, passes | |
| 983 | | No deadline on Get in `boundedRunner` | `go test ./internal/hostedctl -run 'TestProviderCallsBounded$' -count=1` | `refresh_test.go:783: unbounded provider calls: [get: deadline set false, ... get: ...]` | yes, passes | |
| 984 | | No deadline on the network audit | same | `refresh_test.go:783: unbounded provider calls: [audit: deadline set false, ... audit: ...]` | yes, passes | |
| 985 | | `refreshOne` hands `mirrorLive` the detached context | `go test ./internal/hostedctl -run 'TestRefreshRecoveryCallsCancel$' -count=1` | `refresh_test.go:855: Refresh still in its suspend call 5 s after its context was cancelled` | yes, passes | |
| 986 | | Only the resume re-send gets the detached context | same | `refresh_test.go:855: Refresh still in its resume call 5 s after its context was cancelled` | yes, passes | |
| 987 | |
| 988 | ### Budgets (R31) and the final runs |
| 989 | |
| 990 | - `make budget` after the fixes: `internal/hostedctl: 5153 source lines, ceiling 5000` and `8251 |
| 991 | test lines, ceiling 8000`. One size record added to `.rastrillo/budgets.txt` with R31's reason; |
| 992 | `make budget` then reports 96 directories within budget. |
| 993 | - `go test ./internal/hostedctl ./internal/hostedclient ./internal/hostedwire ./internal/isolatedjob/... |
| 994 | ./cmd/equipo-hosted-controller -count=1`: all ok (hostedctl 6.9 s, hostedclient 1.0 s, hostedwire |
| 995 | 0.03 s, isolatedjob 0.36 s, awsjob 0.006 s, command 0.53 s). |
| 996 | - `EQUIPO_SIM_SEEDS=2000 go test ./internal/hostedctl -run TestLifecycleSimulation -count=1`: PASS in |
| 997 | 30.5 s; no invariant loosened (I5's model was tightened for B2-4). |
| 998 | - `make build vet`, `TestProviderTypesStayInAdapter`, `python3 scripts/ci-test.py check`: clean. |
| 999 | |
| 1000 | ### Residual B2-1 (re-review): pending stops retried before replay |
| 1001 | |
| 1002 | - `reapOverdue` now selects every Ref'd, unproven job at or past its stop time. A job with a stop |
| 1003 | request, whatever its reason, gets the provider stop again (`resendPendingStop`, under the attempt |
| 1004 | lock, through `resendStop` with the recorded reason; `stop_requested_t` and `stop_reason` are not |
| 1005 | written); one without gets `reapJob` as before. |
| 1006 | - `TestDeadlineStopBeforeSlowReplay` gains a case: a user stop ("done") whose provider call was |
| 1007 | throttled, then a pass with the replay's launch held; the retry has been sent when the launch is |
| 1008 | entered, with the reason and request time unchanged. |
| 1009 | - Budget record updated to the new measure, 5180/8266 source/test lines. |
| 1010 | - Runs: the test, `go test ./internal/hostedctl -count=1` (ok 7.1 s), `EQUIPO_SIM_SEEDS=1000` (PASS, |
| 1011 | 14.1 s), `make budget` (all within budget). |
| 1012 | |
| 1013 | | Mutation | Command | Observed failure | Restored | |
| 1014 | | --- | --- | --- | --- | |
| 1015 | | Early step skips pending stops again (`pending = false && ...`) | `go test ./internal/hostedctl -run 'TestDeadlineStopBeforeSlowReplay$' -count=1` | `reaper_test.go:405: pending true: provider stops while the replay's launch call hung = [vm-0001], want [vm-0001 vm-0001]` | yes, passes | |
| 1016 | |
| 1017 | ## Task 17 pre-flight |
| 1018 | |
| 1019 | Offline preparation for the live check; no AWS call was made. The live pieces compile under |
| 1020 | `hostedlive` and were not run. |
| 1021 | |
| 1022 | ### A3: the contract waits for a new VM to appear |
| 1023 | |
| 1024 | - `isolatedjobtest.Harness` gains `Visibility` (how long Get may answer `ErrNotFound` for a VM Launch |
| 1025 | just returned; zero for the fake, 60 s live) and `CallTimeout` (each Runner call's bound, 30 s by |
| 1026 | default). The contract's `launch` waits for the VM to appear before any check reads it; this wait |
| 1027 | is separate from Settle's state waits. Every Runner call the contract makes, `listUntil`'s Lists |
| 1028 | included, now carries a deadline (closes the deferred Task 6 minor). |
| 1029 | - The live `settle` helper bounds each Get and reads `ErrNotFound` again during the first 60 s, |
| 1030 | unless it waits for a terminal state (gone is then an answer). |
| 1031 | - `TestFakeContractLateVisibility`: the contract over a runner whose Get misses every new VM once, |
| 1032 | and which counts Get and List calls without a deadline. |
| 1033 | - Runs: `go test ./internal/isolatedjob/... -count=1` ok; `go vet -tags hostedlive |
| 1034 | ./internal/isolatedjob/...`; `make build vet`; the Task 7 guard passes. |
| 1035 | |
| 1036 | | Mutation | Command | Observed failure | Restored | |
| 1037 | | --- | --- | --- | --- | |
| 1038 | | Remove the visibility wait (`appear` not called in the contract's `launch`) | `go test ./internal/isolatedjob -run 'TestFakeContract' -count=1` | `contract.go:151: Get(vm-0001) = isolatedjob: not found: vm-0001 is not visible yet` | yes, passes | |
| 1039 | | Drop the per-call deadline (`call` returns `context.WithCancel`) | same | `fake_test.go:136: contract made 19 Get or List calls without a deadline (0 with one), want none without` | yes, passes | |
| 1040 | |
| 1041 | ### The hostedclient live driver |
| 1042 | |
| 1043 | - `internal/hostedclient/live_test.go` (`hostedlive` only): `TestLiveControllerSequence` drives one |
| 1044 | Small VM through a running controller (launch, running, drain, quiescent, suspend, suspended, |
| 1045 | resume with its epoch, running, stop with proof) and logs every timing and the epoch; |
| 1046 | `TestLiveCrashRecovery` is the two-step crash check (`launch` against a controller that exits |
| 1047 | after the provider call, `recover` after a restart: one VM for the attempt in `GET /v1/vms`, then |
| 1048 | stop with proof). Both skip without `EQUIPO_HOSTED_LIVE_URL` and stop their VM on failure. |
| 1049 | - Checks: `go vet -tags hostedlive ./internal/hostedclient`, `go vet ./internal/hostedclient`, |
| 1050 | `go test ./internal/hostedclient -count=1` ok. Not run (live). No guard to mutate. |
| 1051 | |
| 1052 | ### The crash point after launch, and the key files |
| 1053 | |
| 1054 | - `cmd/equipo-hosted-controller/crashpoint.go` (`hostedlive` only) sets `runnerHook`, which `main` |
| 1055 | applies to the runner it hands the controller. With `EQUIPO_HOSTED_CRASH_AFTER_LAUNCH=1` the |
| 1056 | wrapped Launch exits with 137 once the provider has returned a VM, before transaction 2 saves the |
| 1057 | Ref; otherwise the hook returns the runner itself. A normal build has `runnerHook` nil. |
| 1058 | - `TestNoCrashPointWithoutTag` (untagged builds only): `runnerHook` is nil. |
| 1059 | - `TestCrashAfterLaunch` (`hostedlive`, fake runner, injectable exit): the exit comes with 137, the |
| 1060 | fake holds one VM for the attempt, the job is still `waiting` with no Ref; a controller reopened |
| 1061 | on the same database without the variable replays the intent and holds that one VM, `starting`. |
| 1062 | - `TestLiveKeygen` (`hostedlive`, skips without `EQUIPO_HOSTED_KEYGEN_DIR`): writes the controller, |
| 1063 | instance and operator keys, `verify_keys.json`, and a self-signed TLS pair for 127.0.0.1, refusing |
| 1064 | to replace a file, and checks them with the config loader's own readers. |
| 1065 | - Runs: `go test ./cmd/equipo-hosted-controller -count=1` ok; `go test -tags hostedlive |
| 1066 | ./cmd/equipo-hosted-controller -run 'TestCrashAfterLaunch$|TestLiveKeygen$' -count=1` ok (both |
| 1067 | offline: the fake runner, and a keygen run into a scratch directory, since removed); `go vet` with |
| 1068 | and without the tag; `make build vet`; `make budget`; the Task 7 guard. |
| 1069 | |
| 1070 | | Mutation | Command | Observed failure | Restored | |
| 1071 | | --- | --- | --- | --- | |
| 1072 | | Drop the `hostedlive` build line from `crashpoint.go` | `go test ./cmd/equipo-hosted-controller -run 'TestNoCrashPointWithoutTag' -count=1` | `crashpoint_off_test.go:13: runnerHook is set in a build without the hostedlive tag; the Task 17 crash point must not ship` | yes, passes | |
| 1073 | | Exit before the provider call (`crashExit(137)` first in `crashRunner.Launch`) | `go test -tags hostedlive ./cmd/equipo-hosted-controller -run 'TestCrashAfterLaunch$' -count=1` | `crashpoint_test.go:78: provider VMs for crash-1 at the crash = 0, want 1: the exit must come after the provider call` | yes, passes | |
| 1074 | |
| 1075 | ### R32: List sees only the configured images |
| 1076 | |
| 1077 | - The dev account is shared, and the reaper stops any listed VM no job owns after 10 minutes. So |
| 1078 | `awsjob.Runner.List` now makes one `ListMicrovms` walk per configured image ARN (deduplicated, |
| 1079 | sorted), with the SDK's `ImageIdentifier` filter, and reads every page of each. It also drops any |
| 1080 | item whose `imageArn` is not the ARN asked for, so another image's VM is never returned even if |
| 1081 | the filter were ignored. Any page error, repeated token or item with no ID still gives |
| 1082 | `ErrIncomplete` and no jobs. The rule is documented in the `Config.Images` comment and in |
| 1083 | doc.go's List facts. |
| 1084 | - `TestListOnlyConfiguredImages`: two configured images and one other image, two pages each. With |
| 1085 | the filter honoured, and again with a provider that ignores it, only the configured VMs come back, |
| 1086 | through exactly the expected (image, token) calls. A page error on the second image gives |
| 1087 | `ErrIncomplete` with no jobs. `TestListAllPages` and the age rows now expect the filter and carry |
| 1088 | `ImageArn`. |
| 1089 | - Runs: RED first (`TestListAllPages` saw no filter; the new test listed `vm-x1 vm-x2`), then |
| 1090 | `go test ./internal/isolatedjob/awsjob -count=1` ok; `go vet -tags hostedlive`; the Task 7 guard; |
| 1091 | `make build vet`. |
| 1092 | |
| 1093 | | Mutation | Command | Observed failure | Restored | |
| 1094 | | --- | --- | --- | --- | |
| 1095 | | Unfiltered List again (no `ImageIdentifier`, no `imageArn` check) | `go test ./internal/isolatedjob/awsjob -run 'TestListOnlyConfiguredImages' -count=1` | `runner_test.go:1074: List refs = [vm-a1 vm-a1 ... vm-x1 vm-x1 vm-x2 vm-x2], want [vm-a1 vm-a2 vm-b1 vm-b2]: only VMs from the configured images` (and `:1078` calls without the image) | yes, passes | |
| 1096 | | Filter sent, `imageArn` check dropped | same | `runner_test.go:1074: List refs = [... vm-x1 vm-x1 vm-x2 vm-x2], want [vm-a1 vm-a2 vm-b1 vm-b2]` (the provider-ignores-the-filter row) | yes, passes | |
| 1097 | |
| 1098 | ### Code review round 1 (t17-code-review.md) |
| 1099 | |
| 1100 | - The driver logic moved from `live_test.go` to an untagged `liveDriver` |
| 1101 | (`internal/hostedclient/driver_test.go`). Its steps return errors and register their cleanups |
| 1102 | through a hook. `live_test.go` now only reads the environment and calls it, and |
| 1103 | `driver_offline_test.go` runs every path against the test controller, with a goroutine standing |
| 1104 | in for the reaper's refresh. |
| 1105 | - Finding 1: `crashLaunch` and `crashRecover` register the VM guard first (before the Launch, and |
| 1106 | before the operator key is read). Only the intended crash handover (Launch failing in transport) |
| 1107 | releases it, and so does stop proof. Every other ending stops the VM. |
| 1108 | - Finding 2: `stopUntilProof`, and so the cleanup, sends Stop again on transport failure, on an |
| 1109 | unverified answer and on any signed 503, as well as on pending and throttled answers. It reports |
| 1110 | the last error once its bound passes. |
| 1111 | - Minor 3: the sequence fails unless Resume's epoch is the running job's epoch plus one. |
| 1112 | - Evidence (a): the contract logs `visibility: Get showed new VM <ref> <d> after Launch returned |
| 1113 | (<n> reads)` and `list lag: List showed running VM <ref> <d> after Get did (<n> lists)` through |
| 1114 | `Harness.Logf` (nil means t.Logf). |
| 1115 | - Evidence (b): `hostedctl.Deps.Log` (slog; nil discards; `main` sends it to stderr at info) gets |
| 1116 | fixed-message records: |
| 1117 | - orphan stopped: `vm_ref`, `first_seen_ns`, `unclaimed_for`, `grace`, `seen_before_restart`; |
| 1118 | - orphan stop call failed; |
| 1119 | - orphan deferred: also `dispatched_intents`; |
| 1120 | - network audit failed: fixed `kinds` such as `resolver_enabled`, `provider_read_failed`, with no |
| 1121 | error text; |
| 1122 | - restart re-base: `attempt`, `provider_age`, and how far the launch and stop times moved back; |
| 1123 | - restart elapsed_unknown stop. |
| 1124 | - Budget: `internal/hostedctl` record moved to 5288/8388. |
| 1125 | - Tests: |
| 1126 | - `TestDriverSequenceOffline`, `TestDriverCrashLaunchAnsweredStopsVM`, |
| 1127 | `TestDriverCrashLaunchTransportHandsOver`, `TestDriverRecoverBadOperatorKeyStopsVM`, |
| 1128 | `TestDriverStopRetriesTransport` and `TestRetryableStop`, all `-count=10` clean; |
| 1129 | - `TestControllerLogs` (five scenarios, and no provider text or instance code in the log); |
| 1130 | - `TestFakeContractLateVisibility` now also wants both delay lines. |
| 1131 | - Runs: `go test` for hostedclient, hostedctl (6.7 s), isolatedjob/... and the controller command |
| 1132 | all ok; `go vet -tags hostedlive` on the four; `make build vet`; `make budget`; the Task 7 guard; |
| 1133 | `scripts/ci-test.py check`. |
| 1134 | |
| 1135 | | Mutation | Command | Observed failure | Restored | |
| 1136 | | --- | --- | --- | --- | |
| 1137 | | `crashLaunch` registers its guard only after the answered-launch check | `go test ./internal/hostedclient -run 'TestDriverCrashLaunch' -count=1` | `driver_offline_test.go:113: Get(crash-1) = starting, <nil>; want stopped` | yes, passes | |
| 1138 | | `crashRecover` registers its guard after reading the operator key | `go test ./internal/hostedclient -run 'TestDriverRecover' -count=1` | `driver_offline_test.go:149: Get(rec-1) = starting, <nil>; want stopped` | yes, passes | |
| 1139 | | `retryableStop` no longer retries `ErrTransport` | `go test ./internal/hostedclient -run 'TestDriverStopRetriesTransport' -count=1` | `driver_offline_test.go:166: cleanup made 1 calls, want the two failures and a retry` | yes, passes | |
| 1140 | | Epoch check expects no rise (`running.Epoch+0`) | `go test ./internal/hostedclient -run 'TestDriverSequenceOffline' -count=1` | `driver_offline_test.go:95: sequence = Resume gave epoch 1, want 1: one resume raises the epoch by one` (the message prints the unmutated expectation) | yes, passes | |
| 1141 | |
| 1142 | ### Code review round 2 (t17-code-r2-review.md): R36 and seen_before_restart |
| 1143 | |
| 1144 | - `isolatedjob.Ref.Valid`: 1 to 128 letters, digits and '-'. Neither the API reference nor the SDK |
| 1145 | documents a syntax for `microvmId`, so ruling R36's fallback applies. |
| 1146 | - awsjob rejects an ID that fails the check: |
| 1147 | - RunMicrovm: a fixed error; |
| 1148 | - GetMicrovm: a fixed error; |
| 1149 | - any ListMicrovms item: `ErrIncomplete` with no jobs; |
| 1150 | - a malformed ref passed to Get, Suspend, Resume or Stop: `ErrInvalid` before any provider call. |
| 1151 | No error quotes the ID. doc.go records it. |
| 1152 | - hostedctl's `boundedRunner`, the one way runner answers reach the controller, checks every Ref |
| 1153 | again. A Launch with a bad Ref becomes a provider failure, so the intent stays waiting with no |
| 1154 | Ref. A bad Get becomes an error, and a List holding one becomes `ErrIncomplete`. So no stored or |
| 1155 | logged Ref can carry other text. |
| 1156 | - `seen_before_restart` is now `Restarted() && firstSeen < OpenedAt()`, the reaper's own rule. |
| 1157 | - Tests: |
| 1158 | - `TestMalformedIDsRefused` (awsjob): a sentinel ID, a 129-character one, `vm/1` and a trailing |
| 1159 | newline, each on Run, Get and List, and malformed refs passed in; |
| 1160 | - `TestMalformedRefsNeverStoredOrLogged` (hostedctl): Launch, Get and List with a sentinel ref; |
| 1161 | no job ref, unmatched VM, audit row, log line or error holds it; |
| 1162 | - `TestControllerLogs` gains an orphan first seen before a restart and stopped more than the grace |
| 1163 | later (`seen_before_restart=true`), and the plain case says `false`. |
| 1164 | - Budget: hostedctl record moved to 5313/8489. |
| 1165 | - Runs: |
| 1166 | - hostedctl 7.3 s and 6.7 s (budget 10 s); |
| 1167 | - awsjob, isolatedjob, hostedclient and the controller command ok; |
| 1168 | - tagged vets, `make build vet`, `make budget`, the Task 7 guard. |
| 1169 | |
| 1170 | | Mutation | Command | Observed failure | Restored | |
| 1171 | | --- | --- | --- | --- | |
| 1172 | | awsjob checks only for an empty ID again (no validation) | `go test ./internal/isolatedjob/awsjob -run TestMalformedIDsRefused -count=1` | `ids_test.go:36: Launch with id "vm-1 SENTINEL-secret=hunter2" = ("vm-1 SENTINEL-secret=hunter2", <nil>), want an error and no ref` (and the Get and List rows) | yes, passes | |
| 1173 | | hostedctl boundary checks only for an empty Ref | `go test ./internal/hostedctl -run TestMalformedRefsNeverStoredOrLogged -count=1` | `logs_test.go:94: Launch answered with a malformed ref = nil error, want a provider failure` | yes, passes | |
| 1174 | | `seen_before_restart` back to `now-firstSeen < OrphanGrace` | `go test ./internal/hostedctl -run TestControllerLogs -count=1` | `logs_test.go:160: no log line holds [... "seen_before_restart=true"]` | yes, passes | |
| 1175 | |
| 1176 | ### R38 (code review round 3): a Get without a MicroVM ID is an error |
| 1177 | |
| 1178 | - `awsjob.Runner.Get` used to substitute the asked-for ref when the reply's `microvmId` was empty or |
| 1179 | absent. It now always validates the reply's ID; missing or malformed is a fixed error. Run and |
| 1180 | List already required a valid ID; no other reply ID is optional. |
| 1181 | - `TestMalformedIDsRefused` adds Get replies with an empty and a nil ID (state TERMINATED). |
| 1182 | `TestGetWithoutRefNeverProof` (hostedctl): a Get that answers stopped but names no VM yields no |
| 1183 | proof through Stop, Refresh or a reaper pass. |
| 1184 | - Budget: hostedctl test lines record moved to 8516. |
| 1185 | - Runs: awsjob and isolatedjob ok; hostedctl ok (6.8 s); tagged vets; `make build vet`; |
| 1186 | `make budget`; the Task 7 guard. |
| 1187 | |
| 1188 | | Mutation | Command | Observed failure | Restored | |
| 1189 | | --- | --- | --- | --- | |
| 1190 | | Get substitutes the asked-for ref for an empty ID again | `go test ./internal/isolatedjob/awsjob -run TestMalformedIDsRefused -count=1` | `ids_test.go:73: Get answered with a nil id = ({Ref:vm-1 State:stopped ...}, <nil>), want an error and no job` (and the empty row) | yes, passes | |
| 1191 | | hostedctl boundary skips the Get check | `go test ./internal/hostedctl -run TestGetWithoutRefNeverProof -count=1` | `logs_test.go:147: Stop with a Get naming no VM = proof {AttemptID:att-1 VMRef:vm-0001 State:stopped ObservedAt:0}, want none` | yes, passes | |
| 1192 | |
| 1193 | ## Task 17 live run |
| 1194 | |
| 1195 | Plan revision 3 (`30d21b0a`), code `a7f505a0`, account `640012953448` (profile `kass`), `eu-west-1`. |
| 1196 | Attempt 1 (revision 2, run `1123-eef187`) stopped at 0.4 with nothing created; its journal is kept |
| 1197 | outside the repo. This is attempt 2, run `1124-5415de`, started 2026-11-24 13:01Z. |
| 1198 | |
| 1199 | ### Section 0 |
| 1200 | |
| 1201 | - 0.1: code pin ok (`a7f505a0`); aws-cli 2.36.10; go1.26.10. |
| 1202 | - 0.1a: attempt 1 scratch removed; its journal kept. |
| 1203 | - 0.3: `640012953448`, `arn:aws:iam::640012953448:user/remote-agent`. |
| 1204 | - 0.4: 0 live MicroVMs in the account and region; nothing tagged `purpose=equipo-hosted-dev`; |
| 1205 | collision checks clean. |
| 1206 | - Estimate (11.2): 0 VMs, $0.21 (fixed items only). |
| 1207 | |
| 1208 | ### Section 1 |
| 1209 | |
| 1210 | - VPC `vpc-0a9ff3150edc03416` (10.177.0.0/16), DNS support and hostnames off; defaults tagged |
| 1211 | (`sg-0393fe63d3c4fa54a`, `rtb-09519508746c93ec6`, `acl-0e7cd3a6c5a00fc51`, two default rules). |
| 1212 | - Subnet `subnet-0ed61e4aa0ff739ab` (10.177.1.0/24, eu-west-1a, no public IPs). |
| 1213 | - Route table `rtb-083c469ecf048d3c5`: local route only, associated. |
| 1214 | - Security group `sg-06a1e195e5f7a13dd`: no rules. |
| 1215 | - Estimate (11.2): $0.21. |
| 1216 | |
| 1217 | ### Section 2: stopped at 2.2 (safe stop run) |
| 1218 | |
| 1219 | - 2.1: operator role `arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1124-5415de-conn-op` |
| 1220 | with the inline policy `t17-connector-eni` (scoped to the subnet and group), created 13:03:33Z. |
| 1221 | - 2.2, 13:03:54Z: `create-network-connector` refused: |
| 1222 | `InvalidParameterValueException ... CreateNetworkConnector operation: Encountered unauthorized |
| 1223 | operation while calling EC2 due to invalid ConnectorOperatorRole permissions`. This is stop |
| 1224 | point U2 (the scoped operator policy); the policy was not widened. |
| 1225 | - Safe stop: S.1 no controller; S.2 `NOTCREATED connector`, nothing unresolved; S.3 skipped (no |
| 1226 | image). Estimate (11.2): 0 VMs, $0.21 (fixed items; actual spend about $0). |
| 1227 | - Left in place for Paul (S.4, no listed charge): the VPC and its defaults, the subnet, the route |
| 1228 | table and its association, the security group, the operator role. Teardown waits for Paul's word. |
| 1229 | |
| 1230 | ### Teardown of attempt 2 (Paul's ruling 2026-11-25, discussion 46) |
| 1231 | |
| 1232 | Run `1124-5415de` only, in `kass` / `640012953448` / `eu-west-1` (IAM global), using the plan's |
| 1233 | section 10 blocks at `30d21b0a` and the run's ledger. A block runs only for resources with a |
| 1234 | `CONFIRMED` record; anything never created is skipped. |
| 1235 | |
| 1236 | - 10.1 (image, versions, VMs), 10.2 (connector, interfaces), 10.5 (S3), 10.6 (log group) and |
| 1237 | 10.7 (SNS): skipped, never created (the connector is `NOTCREATED` in S.2; no VM, interface, |
| 1238 | image, bucket, object, log group or topic records). |
| 1239 | - 10.3 ran as written: deleted `sg-06a1e195e5f7a13dd`, `rtbassoc-01d2371400574d7b2`, |
| 1240 | `rtb-083c469ecf048d3c5`, `subnet-0ed61e4aa0ff739ab` and `vpc-0a9ff3150edc03416` (with it the |
| 1241 | default group `sg-0393fe63d3c4fa54a` and its two rules, the main route table |
| 1242 | `rtb-09519508746c93ec6` and the default ACL `acl-0e7cd3a6c5a00fc51`). Each was confirmed by a |
| 1243 | filtered describe listing 0. |
| 1244 | - 10.4: only its operator-role lines ran (the same calls, behind the same guard), because the |
| 1245 | build role was never created and its `delete-role` would fail. Deleted the inline policy |
| 1246 | `t17-connector-eni`, then the role `equipo-hosted-dev-t17-1124-5415de-conn-op`. `get-role` |
| 1247 | answers `NoSuchEntity`. |
| 1248 | - Verification by type (2026-11-25 19:26Z, direct reads): VPC, subnet, both route tables, the |
| 1249 | association, both groups, both default rules and the ACL each list 0, and no interfaces are |
| 1250 | left in the VPC. IAM `get-role` answers `NoSuchEntity` for both role names. |
| 1251 | - 10.8 ran without `IMAGE_ARN` in its `need` line (no image was ever recorded): |
| 1252 | - 0 VMs recorded. |
| 1253 | - The only "creations without a deletion" are two key mismatches in the plan's classification. |
| 1254 | The role's `DELETED` line names the role, while its `CONFIRMED` line holds the ARN. The |
| 1255 | default rules had no `DELETED` line, and one was added after the direct read. |
| 1256 | - Tag index, by `run=1124-5415de` and by `purpose=equipo-hosted-dev` (19:26Z, and again at |
| 1257 | 19:27Z): only the deleted default group `sg-0393fe63d3c4fa54a` and its rules |
| 1258 | `sgr-0eabb0a8499ad2b8d` and `sgr-07d4a701a0947630f` are still listed. That is index lag: the |
| 1259 | direct reads show them gone. Nothing else is listed. |
| 1260 | - Left in AWS: nothing. Spend for attempt 2: about $0 (no VM, image, bucket, logs or topic). |
| 1261 | |
| 1262 | Journal (attempt 2, intents and controller lines omitted, as in 10.9): |
| 1263 | |
| 1264 | ``` |
| 1265 | RUN 1124-5415de start pin=a7f505a0d69a2459062c83cb46baf7882e261c5f |
| 1266 | COLLISION-CHECKS clean |
| 1267 | CONFIRMED VPC vpc-0a9ff3150edc03416 |
| 1268 | CONFIRMED DEF_SG sg-0393fe63d3c4fa54a |
| 1269 | CONFIRMED MAIN_RTB rtb-09519508746c93ec6 |
| 1270 | CONFIRMED DEF_ACL acl-0e7cd3a6c5a00fc51 |
| 1271 | CONFIRMED DEF_SG_RULES sgr-0eabb0a8499ad2b8d sgr-07d4a701a0947630f |
| 1272 | CONFIRMED SUBNET subnet-0ed61e4aa0ff739ab |
| 1273 | CONFIRMED RTB rtb-083c469ecf048d3c5 |
| 1274 | CONFIRMED RTB_ASSOC rtbassoc-01d2371400574d7b2 |
| 1275 | CONFIRMED SG sg-06a1e195e5f7a13dd |
| 1276 | CONFIRMED OPERATOR_ROLE_ARN arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1124-5415de-conn-op |
| 1277 | ABORT call failed (rc 254, InvalidParameterValueException): | aws: [ERROR]: An error occurred (InvalidParameterValueException) when calling the CreateNetworkConnector operation: Encountered unauthorized operation while calling EC2 due to invalid ConnectorOperatorRole permissions |
| 1278 | NOTCREATED connector equipo-hosted-dev-t17-1124-5415de-egress |
| 1279 | DELETED security-group sg-06a1e195e5f7a13dd |
| 1280 | DELETED route-table-association rtbassoc-01d2371400574d7b2 |
| 1281 | DELETED route-table rtb-083c469ecf048d3c5 |
| 1282 | DELETED subnet subnet-0ed61e4aa0ff739ab |
| 1283 | DELETED vpc vpc-0a9ff3150edc03416 |
| 1284 | DELETED vpc-default-security-group sg-0393fe63d3c4fa54a |
| 1285 | DELETED vpc-main-route-table rtb-09519508746c93ec6 |
| 1286 | DELETED vpc-default-network-acl acl-0e7cd3a6c5a00fc51 |
| 1287 | DELETED iam-role equipo-hosted-dev-t17-1124-5415de-conn-op |
| 1288 | VERIFY direct reads: every recorded resource gone |
| 1289 | DELETED vpc-default-security-group-rule sgr-0eabb0a8499ad2b8d gone with sg-0393fe63d3c4fa54a; describe-security-group-rules filter lists 0 (2026-11-25 19:26Z) |
| 1290 | DELETED vpc-default-security-group-rule sgr-07d4a701a0947630f gone with sg-0393fe63d3c4fa54a; describe-security-group-rules filter lists 0 (2026-11-25 19:26Z) |
| 1291 | TEARDOWN attempt 2 done: 10.3 as written; 10.4 operator-role lines only (build role never created); 10.1 10.2 10.5 10.6 10.7 skipped (never created) |
| 1292 | ``` |
| 1293 | |
| 1294 | VM ledger (`vms.tsv`): empty, no VM was launched. |
| 1295 | |
| 1296 | ### Attempt 3 (plan revision 4 at `c5f9bc36`, code `a7f505a0`, run `1126-c01121`) |
| 1297 | |
| 1298 | Started 2026-11-26 11:18Z. Every block was extracted verbatim from `c5f9bc36` and run with the |
| 1299 | agent sandbox off. |
| 1300 | |
| 1301 | #### Attempt 3, section 0 |
| 1302 | |
| 1303 | - 0.1: code pin ok; aws-cli 2.36.10; go1.26.10. 0.1a: no earlier scratch, nothing to remove. |
| 1304 | - 0.3: `640012953448`, `user/remote-agent`. 0.4: 0 live MicroVMs; nothing tagged |
| 1305 | `purpose=equipo-hosted-dev`; collision checks clean. Estimate: $0.21 (fixed items). |
| 1306 | |
| 1307 | #### Attempt 3, section 1 |
| 1308 | |
| 1309 | - VPC `vpc-0fca2d577ca433d82`, DNS off; defaults `sg-04486f43343aa2423`, `rtb-0c96c86355176c103`, |
| 1310 | `acl-0de2037b6cfee48c7`, rules `sgr-0b198bb6a3fc81262` and `sgr-0262fe4480ff4ef56`, all tagged. |
| 1311 | - Subnet `subnet-0404401a8cd7d255d`; route table `rtb-06096f98e685c2bc1` (local route only, |
| 1312 | associated); security group `sg-0df60ecf755a35e99` (no rules). Estimate: $0.21. |
| 1313 | |
| 1314 | #### Attempt 3, section 2: stopped at 2.4 (safe stop run) |
| 1315 | |
| 1316 | - 2.1: role `arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1126-c01121-conn-op`, narrow |
| 1317 | inline policy, 60 s wait (11:20:07Z to 11:21:13Z). |
| 1318 | - 2.2, the connector: |
| 1319 | - Attempt 1 (11:21:21Z, 74 s after the role was created) was refused with the same error as |
| 1320 | attempt 2: `InvalidParameterValueException`, "invalid ConnectorOperatorRole permissions". |
| 1321 | - Attempt 2 (11:23:39Z, after a further 120 s) was refused the same way. Both were confirmed |
| 1322 | `NOTCREATED`. Propagation is therefore ruled out: the narrow policy lacks something the |
| 1323 | connector needs. |
| 1324 | - Fallback: the role got `AWSLambdaNetworkConnectorOperatorPolicy` plus an inline |
| 1325 | `t17-connector-eni-delete`. |
| 1326 | - Attempt 3 (11:26:58Z) was accepted: connector `nc-9027ec0e-413c-45c2-8233-70242dda0764`, |
| 1327 | `PENDING`. `CONN_OPERATOR_POLICY` = managed policy plus inline delete. |
| 1328 | - 2.3: `ACTIVE` at 11:31:23Z, about 4.4 min after create (16 polls). |
| 1329 | - 2.4 aborted: `connector version is [None]`. The installed CLI (aws-cli 2.36.10) has no `Version` |
| 1330 | field in `get-network-connector`, and none in the create reply either (its keys are Arn, |
| 1331 | Configuration, Id, Name, OperatorRole and State). This is U3, the old CLI model. |
| 1332 | - Safe stop: S.1 no controller; S.2 nothing unresolved; S.3 skipped (no image). Estimate: 0 VMs, |
| 1333 | $0.21 (fixed items; real spend about $0). |
| 1334 | - Left in place for Paul (S.4, no listed charge): |
| 1335 | - the VPC with its defaults, the subnet, the route table and its association, and the group; |
| 1336 | - the operator role, with the managed policy attached and the inline delete policy; |
| 1337 | - the ACTIVE connector and its Lambda-managed interfaces in the subnet. These were not recorded, |
| 1338 | because 2.4 stopped before its interface read. |
| 1339 | |
| 1340 | #### Attempt 3, discovery against the live connector (Paul, 2026-11-28, discussion 46) |
| 1341 | |
| 1342 | These were read-only calls on connector `nc-9027ec0e-413c-45c2-8233-70242dda0764`, behind the |
| 1343 | account guard, at 14:59Z. |
| 1344 | |
| 1345 | - The literal `--network-connector-identifier` flag fails CLI parameter validation (rc 252, no |
| 1346 | request sent). The CLI's flag is `--identifier`. |
| 1347 | - `get-network-connector --identifier <arn>:1` succeeds: `Version` 1, `State` ACTIVE, |
| 1348 | `StateReason` "Initial creation", `LastModified` 2026-11-26T11:31:09Z. The CLI shows no |
| 1349 | `VersionArn`. |
| 1350 | - The unqualified read's raw response body (from `--debug`) holds `LatestVersion: 1` and |
| 1351 | `LatestVersionArn: <arn>:1`. It has no `Version`, `VersionArn`, `StateReasonCode` or |
| 1352 | `LastUpdateStatus`. The CLI output drops `LatestVersion*`, so `--query Version` gives `None` |
| 1353 | (the cause of 2.4's abort). The response carries a `Date` header. |
| 1354 | - Network interfaces: 0 in the run's VPC and 0 in its subnet while the connector is ACTIVE, so |
| 1355 | there were no `SERVICE-ENI` lines to journal. |
| 1356 | |
| 1357 | #### Attempt 3, teardown (revision 4's section 10, as written) |
| 1358 | |
| 1359 | - 10.1: no controller; `SKIP IMAGE_ARN`. |
| 1360 | - 10.2: `delete-network-connector` at 15:00:00Z; DELETING at 15:00:03Z; not found by 15:00:19Z |
| 1361 | (about 19 s); interfaces in the VPC 0. No DELETE_FAILED. |
| 1362 | - 10.3: deleted the group `sg-0df60ecf755a35e99`, association `rtbassoc-07254c8e1b8d2f5e6`, |
| 1363 | route table `rtb-06096f98e685c2bc1`, subnet `subnet-0404401a8cd7d255d` and VPC |
| 1364 | `vpc-0fca2d577ca433d82`. The defaults `sg-04486f43343aa2423` (with rules |
| 1365 | `sgr-0b198bb6a3fc81262` and `sgr-0262fe4480ff4ef56`), `rtb-0c96c86355176c103` and |
| 1366 | `acl-0de2037b6cfee48c7` were each confirmed gone by a filtered describe listing 0. |
| 1367 | - 10.4: the operator role, its inline `t17-connector-eni-delete` and the |
| 1368 | `AWSLambdaNetworkConnectorOperatorPolicy` attachment removed; `get-role` gives `NoSuchEntity`. |
| 1369 | `SKIP BUILD_ROLE_ARN`. |
| 1370 | - 10.5, 10.6 and 10.7: `SKIP` (bucket, log group and topic never created). |
| 1371 | - 10.8: |
| 1372 | - 0 VMs. |
| 1373 | - Unmatched values: only `CONN_ID` (the deleted connector's ID) and the `CONN_OPERATOR_POLICY` |
| 1374 | label. Neither is a separate resource. |
| 1375 | - Tag index, by `run=1126-c01121` and by `purpose=equipo-hosted-dev`: only the deleted default |
| 1376 | group and its two rules, and the deleted connector. That is index lag; the direct reads show |
| 1377 | them gone. |
| 1378 | - Left in AWS: nothing. Spend for attempt 3: about $0 (0 VMs; no image, bucket, logs or topic). |
| 1379 | |
| 1380 | Journal (attempt 3, intents and controller lines omitted, as in 10.9): |
| 1381 | |
| 1382 | ``` |
| 1383 | RUN 1126-c01121 start pin=a7f505a0d69a2459062c83cb46baf7882e261c5f |
| 1384 | COLLISION-CHECKS clean |
| 1385 | CONFIRMED VPC vpc-0fca2d577ca433d82 |
| 1386 | CONFIRMED DEF_SG sg-04486f43343aa2423 |
| 1387 | CONFIRMED MAIN_RTB rtb-0c96c86355176c103 |
| 1388 | CONFIRMED DEF_ACL acl-0de2037b6cfee48c7 |
| 1389 | CONFIRMED DEF_SG_RULES sgr-0b198bb6a3fc81262 sgr-0262fe4480ff4ef56 |
| 1390 | CONFIRMED SUBNET subnet-0404401a8cd7d255d |
| 1391 | CONFIRMED RTB rtb-06096f98e685c2bc1 |
| 1392 | CONFIRMED RTB_ASSOC rtbassoc-07254c8e1b8d2f5e6 |
| 1393 | CONFIRMED SG sg-0df60ecf755a35e99 |
| 1394 | CONFIRMED OPERATOR_ROLE_ARN arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1126-c01121-conn-op |
| 1395 | REFUSED connector attempt 1: | aws: [ERROR]: An error occurred (InvalidParameterValueException) when calling the CreateNetworkConnector operation: Encountered unauthorized operation while calling EC2 due to invalid ConnectorOperatorRole permissions |
| 1396 | NOTCREATED connector attempt 1 |
| 1397 | REFUSED connector attempt 2: | aws: [ERROR]: An error occurred (InvalidParameterValueException) when calling the CreateNetworkConnector operation: Encountered unauthorized operation while calling EC2 due to invalid ConnectorOperatorRole permissions |
| 1398 | NOTCREATED connector attempt 2 |
| 1399 | FALLBACK operator role: AWSLambdaNetworkConnectorOperatorPolicy plus inline delete (Paul, 2026-11-25) |
| 1400 | CONFIRMED OPERATOR_MANAGED_POLICY arn:aws:iam::aws:policy/AWSLambdaNetworkConnectorOperatorPolicy |
| 1401 | CONFIRMED OPERATOR_INLINE_POLICY t17-connector-eni-delete |
| 1402 | CONFIRMED CONN_OPERATOR_POLICY managed AWSLambdaNetworkConnectorOperatorPolicy plus inline delete |
| 1403 | CONFIRMED CONN_ARN arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-9027ec0e-413c-45c2-8233-70242dda0764 |
| 1404 | CONFIRMED CONN_ID nc-9027ec0e-413c-45c2-8233-70242dda0764 |
| 1405 | TIMING connector-active |
| 1406 | ABORT connector version is [None] |
| 1407 | SKIP IMAGE_ARN none |
| 1408 | DISCOVERY start (Paul 2026-11-28, disc 46): read-only, connector arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-9027ec0e-413c-45c2-8233-70242dda0764 |
| 1409 | FACT discovery a0: --network-connector-identifier rc=252 (CLI flag is --identifier) |
| 1410 | FACT discovery a: :1 read ok, keys ["Arn","Configuration","Id","LastModified","Name","OperatorRole","State","StateReason","Version"], Version=1, State=ACTIVE |
| 1411 | FACT discovery b: unqualified read rc=0, CLI keys ["Arn","Configuration","Id","LastModified","Name","OperatorRole","State","StateReason"], Date header present |
| 1412 | FACT discovery c: 0 interfaces in the VPC, 0 in the subnet |
| 1413 | SKIP IMAGE_ARN none |
| 1414 | DELETED connector arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-9027ec0e-413c-45c2-8233-70242dda0764 |
| 1415 | DELETED security-group sg-0df60ecf755a35e99 |
| 1416 | DELETED route-table-association rtbassoc-07254c8e1b8d2f5e6 |
| 1417 | DELETED route-table rtb-06096f98e685c2bc1 |
| 1418 | DELETED subnet subnet-0404401a8cd7d255d |
| 1419 | DELETED vpc vpc-0fca2d577ca433d82 |
| 1420 | DELETED vpc-default-security-group-rules sgr-0b198bb6a3fc81262 sgr-0262fe4480ff4ef56 |
| 1421 | DELETED vpc-default-security-group sg-04486f43343aa2423 |
| 1422 | DELETED vpc-main-route-table rtb-0c96c86355176c103 |
| 1423 | DELETED vpc-default-network-acl acl-0de2037b6cfee48c7 |
| 1424 | DELETED iam-role arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1126-c01121-conn-op |
| 1425 | DELETED iam-inline-policy t17-connector-eni-delete |
| 1426 | DELETED iam-managed-attachment arn:aws:iam::aws:policy/AWSLambdaNetworkConnectorOperatorPolicy |
| 1427 | SKIP BUILD_ROLE_ARN none |
| 1428 | SKIP BUCKET_CREATED none |
| 1429 | SKIP LOG_GROUP_CREATED none |
| 1430 | SKIP TOPIC_ARN none |
| 1431 | ``` |
| 1432 | |
| 1433 | VM ledger (`vms.tsv`): empty, no VM was launched. |
| 1434 | |
| 1435 | ### Revision 5 pre-flight: `livectl` (ruling R40) |
| 1436 | |
| 1437 | - `internal/isolatedjob/awsjob/livectl` (package main, `hostedlive` on every file) makes each Lambda |
| 1438 | MicroVMs and Lambda core call of the live run through the pinned SDK. It has one subcommand per |
| 1439 | operation: |
| 1440 | - `connector` create, get, list-versions, wait-active, delete and wait-gone; |
| 1441 | - `image` base-versions, create, update, get, get-version, list, wait-version and delete; |
| 1442 | - `vm` run, get, list, suspend, resume, terminate and wait-state; |
| 1443 | - `caller`. |
| 1444 | - Each subcommand prints the SDK's whole output struct as JSON (every field, null when absent). |
| 1445 | `ResultMetadata` shows the response's `ServerTime` and `RequestID`. |
| 1446 | - Failures are one JSON line on stderr. Exit codes: 2 API, 3 usage, 4 guard, 5 wait timeout, |
| 1447 | 6 failed state, 1 other. |
| 1448 | - Guards: |
| 1449 | - account `640012953448` and region `eu-west-1` are build constants, checked through STS before |
| 1450 | any other call; |
| 1451 | - creates need a name (VM runs: the image's name and the client token) inside |
| 1452 | `equipo-hosted-dev-t17-RUN`; |
| 1453 | - deletes, updates and VM state changes read their target first. |
| 1454 | - It sits inside the adapter subtree, so the provider guard needs no change. |
| 1455 | - Runs: |
| 1456 | - `go test -tags hostedlive ./internal/isolatedjob/awsjob/livectl -count=1` ok; |
| 1457 | - `go vet -tags hostedlive ./internal/isolatedjob/...`, `make build vet` and `make budget`; |
| 1458 | - the Task 7 guard passes unchanged. |
| 1459 | - No AWS call was made. |
| 1460 | |
| 1461 | | Mutation | Command | Observed failure | Restored | |
| 1462 | | --- | --- | --- | --- | |
| 1463 | | Account and region guard skipped (`checkCaller` returns nil at once) | `go test -tags hostedlive ./internal/isolatedjob/awsjob/livectl -run TestAccountRegionGuard -count=1` | `main_test.go:469: livectl ["connector" "get" "-id" "nc-1"] = exit 0, want 4` | yes, passes | |
| 1464 | | Run-prefix guard skipped (`inRun` returns nil at once) | `go test -tags hostedlive ./internal/isolatedjob/awsjob/livectl -run TestRunPrefixGuard -count=1` | `main_test.go:500: livectl ["connector" "create" "-name" "equipo-hosted-dev-t17-1128-abc123-conn" ...] = exit 0, want 4` | yes, passes | |
| 1465 | |
| 1466 | #### livectl review round 1 (livectl-r1.md) |
| 1467 | |
| 1468 | - **Endpoints (Critical).** `newClients` builds all three clients (STS, Lambda MicroVMs, Lambda core) |
| 1469 | with: |
| 1470 | - the configured endpoint dropped (`BaseEndpoint` nil), which covers `AWS_ENDPOINT_URL`, |
| 1471 | `AWS_ENDPOINT_URL_<SERVICE>` and a profile's `endpoint_url` or `services` section; |
| 1472 | - FIPS and dual-stack off, the region pinned to eu-west-1, and the SDK's default resolver. |
| 1473 | |
| 1474 | `TestClientsIgnoreEndpointOverrides` sets every override in the environment and a profile, then |
| 1475 | records each request's host offline. The hosts must equal the clean ones, |
| 1476 | `sts.eu-west-1.amazonaws.com` and `lambda.eu-west-1.amazonaws.com`. |
| 1477 | - **Retries.** Every client uses `aws.NopRetryer` and `RetryMaxAttempts` 1, whatever |
| 1478 | `AWS_MAX_ATTEMPTS` and the profile's `max_attempts` and `retry_mode` say. |
| 1479 | `TestClientsOneAttempt` sends one request per call on a 500 and on a 429. |
| 1480 | - **Deadlines.** |
| 1481 | - Every operation gets `callTimeout` (60 s) on its context through a stack middleware, the STS |
| 1482 | check included (`TestClientsBoundEachCall`). |
| 1483 | - Waits check their deadline before each read and again after it, so a late success is a |
| 1484 | timeout (`TestWaitNeverSucceedsLate`). They also put the deadline on the reads' context |
| 1485 | (`TestWaitEndsStalledRead`, a stalled read ending at a 1 s wait). |
| 1486 | - A 1m wait every 15 s now reads 4 times, not 5. |
| 1487 | - **Evidence.** |
| 1488 | - The account and region guards each have their own test. |
| 1489 | - `TestRunPrefixGuard` has one subtest per guard, including the VM client token alone (an image |
| 1490 | in the run with a token outside it). |
| 1491 | - `TestServerTimePrinted` shows a populated `ResultMetadata.ServerTime` from a real client's |
| 1492 | response. |
| 1493 | - Runs: the package's offline tests ok (1.6 s); tagged vets; `make build vet`; `make budget`; the |
| 1494 | Task 7 guard. |
| 1495 | |
| 1496 | | Mutation (each alone) | Command (`go test -tags hostedlive ./internal/isolatedjob/awsjob/livectl -count=1 -run ...`) | Observed failure | Restored | |
| 1497 | | --- | --- | --- | --- | |
| 1498 | | Account check off | `TestAccountGuard$` | `main_test.go:469: livectl ["connector" "get" "-id" "nc-1"] = exit 0, want 4` | yes, passes | |
| 1499 | | Region check off | `TestRegionGuard$` | `main_test.go:482: livectl ["-run" "1128-abc123" "vm" "terminate" "-id" "vm-1"] = exit 0, want 4` | yes, passes | |
| 1500 | | connector create's prefix check off | `TestRunPrefixGuard/connector_create,_another_run` | `main_test.go:568: livectl [... "connector" "create" "-name" "equipo-hosted-dev-t17-other-conn" ...] = exit 0, want 4` | yes, passes | |
| 1501 | | image create's prefix check off | `TestRunPrefixGuard/image_create` | `main_test.go:568: livectl [... "image" "create" "-name" "someone-else" ...] = exit 0, want 4` | yes, passes | |
| 1502 | | vm run's image-name check off | `TestRunPrefixGuard/vm_run,_image_outside` | `main_test.go:568: livectl [... "vm" "run" "-image" "...:microvm-image:runner" ...] = exit 0, want 4` | yes, passes | |
| 1503 | | vm run's client-token check off | `TestRunPrefixGuard/vm_run,_token_outside` | `main_test.go:568: livectl [... "vm" "run" "-image" "...:microvm-image:equipo-hosted-dev-t17-1128-abc123-image" ...] = exit 0, want 4` | yes, passes | |
| 1504 | | connector delete's read-and-check off | `TestRunPrefixGuard/connector_delete` | `main_test.go:568: livectl ["-run" "1128-abc123" "connector" "delete" "-id" "nc-prod"] = exit 0, want 4` | yes, passes | |
| 1505 | | image delete's read-and-check off | `TestRunPrefixGuard/image_delete` | `main_test.go:568: livectl ["-run" "1128-abc123" "image" "delete" "-id" "arn:runner"] = exit 0, want 4` | yes, passes | |
| 1506 | | image update's read-and-check off | `TestRunPrefixGuard/image_update` | `main_test.go:568: livectl [... "image" "update" "-id" "arn:runner" ...] = exit 0, want 4` | yes, passes | |
| 1507 | | VM change read-and-check off (terminate, suspend, resume) | `TestRunPrefixGuard/vm_terminate` | `main_test.go:568: livectl ["-run" "1128-abc123" "vm" "terminate" "-id" "vm-x"] = exit 0, want 4` | yes, passes | |
| 1508 | | Wait: expiry check before each read off | `TestBoundedWaits$` | `main_test.go:601: reads in a 1m wait every 15s = 5, want 4` | yes, passes | |
| 1509 | | Wait: expiry check after each read off | `TestWaitNeverSucceedsLate$` | `main_test.go:647: livectl ["connector" "wait-active" "-id" "nc-1" "-timeout" "1m"] = exit 0, want 5` | yes, passes | |
| 1510 | | Wait: deadline not put on the reads' context | `TestWaitEndsStalledRead$` | `main_test.go:666: a 1s wait on a stalled read took 5.001910063s` | yes, passes | |
| 1511 | | STS endpoint override kept | `TestClientsIgnoreEndpointOverrides$` | `clients_test.go:158: hosts under overrides = [evil-sts.invalid lambda.eu-west-1.amazonaws.com ...], want the standard [sts.eu-west-1.amazonaws.com ...]` | yes, passes | |
| 1512 | | Lambda core retries kept | `TestClientsOneAttempt$` | `clients_test.go:186: status 500: 6 requests for two calls, want one each (no retries)` | yes, passes | |
| 1513 | | STS per-call deadline dropped | `TestClientsBoundEachCall$` | `clients_test.go:210: stalled call 0 = ... request send failed, the request had no deadline, want the per-call deadline` | yes, passes | |
| 1514 | |
| 1515 | #### livectl review round 2 (livectl-r2.md): static credentials only (R41) |
| 1516 | |
| 1517 | - `resolveCredentials` (creds.go) runs once, in `main`, before the account check. It reads only the |
| 1518 | environment and the selected profile of the shared config and credentials files, and takes |
| 1519 | static keys: the environment's first, else the profile's. |
| 1520 | - Refused with exit 4 and a fixed message naming the kind: web identity (profile or environment), |
| 1521 | SSO (session or legacy), `credential_process`, `credential_source` (container or instance |
| 1522 | metadata), assume role, login session, container credentials from the environment, and no static |
| 1523 | keys at all (named instance metadata, the SDK's last fallback). |
| 1524 | - None of those providers is built. `main` no longer calls `LoadDefaultConfig`: the only config is |
| 1525 | the region plus a fixed provider that never expires (`fixedCredentials`). So no credential |
| 1526 | service client exists, nothing refreshes, and the per-call deadlines cover every request. |
| 1527 | - Tests: |
| 1528 | - `TestCredentialKindsRefused`: eleven cases from config files in `t.TempDir` and the |
| 1529 | environment. Every credential service endpoint points at a counting 127.0.0.1 server, which |
| 1530 | sees 0 requests, and the `credential_process` marker is never written. |
| 1531 | - `TestStaticCredentialsAccepted`: profile keys, and environment keys winning over a role |
| 1532 | profile. |
| 1533 | - `TestCredentialsNeverRefresh`: two requests are signed with the first keys after the |
| 1534 | environment changes. |
| 1535 | - `TestClientsIgnoreEndpointOverrides` also runs the production path, resolved keys plus |
| 1536 | `staticConfig`. |
| 1537 | - Runs: the package's offline tests ok; tagged vets; `make build vet`; `make budget`; the Task 7 |
| 1538 | guard; `go mod tidy -diff` clean. |
| 1539 | |
| 1540 | | Mutation (each alone) | Command (`go test -tags hostedlive ./internal/isolatedjob/awsjob/livectl -count=1 -run ...`) | Observed failure | Restored | |
| 1541 | | --- | --- | --- | --- | |
| 1542 | | `credential_process` allowed | `TestCredentialKindsRefused/credential_process` | `creds_test.go:99: resolveCredentials = <nil>, want a guard refusal naming "credential_process"` | yes, passes | |
| 1543 | | Assume role allowed | `TestCredentialKindsRefused/assume_role` | `creds_test.go:99: resolveCredentials = guard: credentials from instance metadata are refused ..., want a guard refusal naming "assume role"` | yes, passes | |
| 1544 | | Web identity from the environment allowed | `TestCredentialKindsRefused/web_identity_in_the_environment` | `creds_test.go:99: ... credentials from instance metadata are refused ..., want a guard refusal naming "web identity"` | yes, passes | |
| 1545 | | Refresh re-enabled (keys re-read on every Retrieve) | `TestCredentialsNeverRefresh$` | `creds_test.go:168: requests signed with [AKIDFIRST AKIDSECOND], want the first keys twice` | yes, passes | |
| 1546 | |
| 1547 | ### Attempt 4 (plan revision 5 at `52a771ad`, code `bdf85fb7`, run `1128-4ba61b`) |
| 1548 | |
| 1549 | Started 2026-11-28 17:54Z. Every block was written verbatim to `$T17/blocks/<block>.sh` and run |
| 1550 | with `bash`, sandbox off; Lambda calls go through livectl. |
| 1551 | |
| 1552 | #### Attempt 4, section 0 |
| 1553 | |
| 1554 | - 0.1: code pin ok (`bdf85fb7`); livectl offline tests ok. 0.1a: nothing to remove. |
| 1555 | - 0.2: livectl built. |
| 1556 | - 0.3: CLI and livectl both see `640012953448` in `eu-west-1`, so the exported static keys work |
| 1557 | (U23). |
| 1558 | - 0.4: nothing tagged; collision checks clean. Estimate $0.21. |
| 1559 | |
| 1560 | #### Attempt 4, section 1 |
| 1561 | |
| 1562 | - VPC `vpc-0048e6026eda29270`, DNS off; defaults `sg-0fcee04c7a190c689`, `rtb-0f0e150517b1ef66e`, |
| 1563 | `acl-08cc47b20377a1a05` and rules `sgr-0114f9753b21dd97f` and `sgr-054d5184b83c894d5`, all |
| 1564 | tagged. |
| 1565 | - Subnet `subnet-0e4cc358228df4994`; route table `rtb-0c24bb2e599df089d`; group |
| 1566 | `sg-0cb56fe86467e152b`. Every readback ok, no FINDING. Estimate $0.21. |
| 1567 | |
| 1568 | #### Attempt 4, section 2 |
| 1569 | |
| 1570 | - 2.1: operator role `equipo-hosted-dev-t17-1128-4ba61b-conn-op` with the managed connector policy |
| 1571 | plus the inline subnet-scoped delete; 120 s wait. |
| 1572 | - 2.2: connector `nc-2e892a59-0945-4534-89e9-c636b111fede`, accepted on the first call |
| 1573 | (17:59:08Z). The SDK create reply carries `Version` 1 and `VersionArn <arn>:1`. |
| 1574 | - 2.3: ACTIVE at 18:03:27Z (about 4.3 min). |
| 1575 | - 2.4: |
| 1576 | - The `:1` read is this run's ACTIVE connector, with no Elastic IP configuration. |
| 1577 | - The unqualified read shows `LatestVersion` 1 and `LatestVersionArn <arn>:1` (Version null). |
| 1578 | - One version listed (1, ACTIVE). There are 0 interfaces while the connector is ACTIVE. |
| 1579 | - Estimate $0.21. |
| 1580 | |
| 1581 | #### Attempt 4, sections 3 and 4 |
| 1582 | |
| 1583 | - Bucket `equipo-hosted-dev-t17-1128-4ba61b-640012953448`, log group |
| 1584 | `/aws/lambda-microvms/equipo-hosted-dev-t17-1128-4ba61b` (1 day), build role |
| 1585 | `...-build` (60 s wait). |
| 1586 | - Artifact `t17/app.zip`, digest |
| 1587 | `sha256:ca59e2a1a77f2e44e2b43429073fce30f663ed867d6e444d58fdb29ebaa938c4`; S3 checksum and tag |
| 1588 | ok. |
| 1589 | - 3.6: base `al2023-1` versions 4 and 3 are AVAILABLE with ARM_64 and X86_64; 2, 1 and 0 are ARM_64 |
| 1590 | only. 4 was chosen, with 3 as the step down. |
| 1591 | - 3.7: image `arn:aws:lambda:eu-west-1:640012953448:microvm-image:equipo-hosted-dev-t17-1128-4ba61b` |
| 1592 | created at once (18:05:20Z), Small version `1.0`. |
| 1593 | - 3.8: Small `1.0` SUCCESSFUL ACTIVE at 18:07:11Z (about 1.8 min). The adapter's fields match. The |
| 1594 | version carries the image tags (U19). |
| 1595 | - 3.9: Large version `2.0` built by 18:09:10Z (about 1.8 min); Small still SUCCESSFUL ACTIVE. |
| 1596 | - 4: topic `arn:aws:sns:eu-west-1:640012953448:equipo-hosted-dev-t17-1128-4ba61b-alerts`, tagged, |
| 1597 | no subscriptions. |
| 1598 | - 0 FINDING. Estimate $0.21. |
| 1599 | |
| 1600 | #### Attempt 4, section 5 |
| 1601 | |
| 1602 | - 5.1 to 5.5: keys (`task17-instance` instance, `task17-operator` operator); ports free; configs |
| 1603 | written with `connector_arn` `<arn>:1` and `egress: []`; both controller builds; driver env. |
| 1604 | - 5.6, the audit-only controller: |
| 1605 | - Ready at once: `network_audit_passing 1`, `reap_last_error 0`, `store_readable 1`. It listened |
| 1606 | on 127.0.0.1:18443 and :18444, reported "launches enabled: false", and stopped with exit 0. |
| 1607 | - The database holds `provider_bound` (`aws:640012953448:eu-west-1`) and no audit failures. |
| 1608 | - FINDING: "no network audit passed". The database has no `network_audit_passed` row, because |
| 1609 | the controller writes that row only when an audit passes again after failing |
| 1610 | (`internal/hostedctl/reaper.go:747`, "network audit passes again"). A first pass writes no row. |
| 1611 | The plan's check expects one, so `AUDIT_OK=no` and, by the plan's own branch, sections 7 and 8 |
| 1612 | are skipped (FINDINGs). Sections 6 and 9 still run. |
| 1613 | |
| 1614 | #### Attempt 4, facts 9.A to 9.F (R7) |
| 1615 | |
| 1616 | - U21: A1 launched with the qualified egress ARN (`<conn>:1`), so RunMicrovm accepts it. |
| 1617 | - First real MicroVM ID: `microvm-a8f71284-6226-3160-835a-8f2ba037b9f0`, 44 characters, inside |
| 1618 | R36's form. The format is `microvm-<uuid>`, not `mvm-` (U17): the plan's log harvest pattern |
| 1619 | `mvm-...` does not match it. Image-scoped scans are the inventory. |
| 1620 | - A2 (same token, same body): `same-vm`. |
| 1621 | - A3 (same token, new payload): refused `ValidationException`, "The provided clientToken was used |
| 1622 | with different request parameters." |
| 1623 | - startedAt: |
| 1624 | - The PENDING reply carries `StartedAt` 18:10:24.835Z, inside the call window 18:10:23.815Z to |
| 1625 | 18:10:24.878Z. |
| 1626 | - The first read at 18:10:39.8Z was already RUNNING, with the same `StartedAt`. |
| 1627 | - Echoes: |
| 1628 | - ingress `[...:aws-network-connector:NO_INGRESS]`, the exact literal; |
| 1629 | - egress `[<conn>:1]`; |
| 1630 | - max 600; |
| 1631 | - ExecutionRoleArn null, IdlePolicy null. |
| 1632 | - Date header on GetMicrovm: present (`ServerTime` 18:10:40Z). List: not measured. |
| 1633 | - 0 interfaces in the VPC while VM_A ran. |
| 1634 | - 9.C: |
| 1635 | - resume on RUNNING `accepted` (not ConflictException); |
| 1636 | - suspend 18:10:47.1Z, SUSPENDED by 18:10:49 (about 2 s); |
| 1637 | - suspend on SUSPENDED `accepted`; |
| 1638 | - resume 18:10:50.1Z, then a second resume `accepted:after-first-resume`; |
| 1639 | - RUNNING at 18:10:54 (about 4 s). |
| 1640 | - 9.D, payload (ASCII): 4096 accepted; 4097 refused `ValidationException`, "Value at |
| 1641 | 'runHookPayload' failed to satisfy constraint: Member must have length less than or equal to |
| 1642 | 4096". |
| 1643 | - 9.E: |
| 1644 | - VM_A ended at 18:11:40Z; a second terminate was accepted. |
| 1645 | - E1 (the original token after the VM ended) returned `same-ended-vm`, with no new VM. |
| 1646 | - 9.F: at 18:12:48Z, 68 s after the end, Get still answers TERMINATED and the image list still |
| 1647 | shows VM_A. |
| 1648 | - Estimate: 2 VMs, 0.02 VM-hours, $0.22. |
| 1649 | |
| 1650 | #### Attempt 4, section 6 (contract) |
| 1651 | |
| 1652 | - 6.1, 18:13:05Z to 18:14:01Z: |
| 1653 | - `TestLiveContract` took 35 s. 8 subtests passed: LaunchIdempotentOnAttempt, StopTwice, |
| 1654 | StopUnknownRef, GetAfterStop, SuspendResumeRoundTrip, ResumeRunningIsNoop, |
| 1655 | OversizeBootstrapRefusedBeforeProvider and LimitsAreSane. |
| 1656 | - One failed, recorded as a FINDING: `ChangedSpecConflicts` [known]. RunMicrovm answered 400 |
| 1657 | `ValidationException` "The provided clientToken was used with different request parameters", |
| 1658 | which the adapter does not map to `ErrConflict`. |
| 1659 | - 7 contract VMs, all settled (9 VMs recorded in the run). 0 interfaces in the VPC. |
| 1660 | - Delays: Get showed each new VM 46 to 76 ms after Launch returned, on the first read. List showed |
| 1661 | a running VM 49 ms after Get did, on the first list. The pre-flight's 60 s and 30 s were guesses. |
| 1662 | - Estimate: 9 VMs, 0.10 VM-hours, $0.23. |
| 1663 | |
| 1664 | #### Attempt 4, sections 7 and 8, and 9.G |
| 1665 | |
| 1666 | - 7.1 and 8.1: FINDINGs "section 7 skipped" and "section 8 skipped". The 5.6 check found no |
| 1667 | `network_audit_passed` row (see section 5). 7.2, 7.3, 7.4 and 8.2 ran their skip branches (7.4 |
| 1668 | settled: 9 VMs, none live). The controller sequence, the crash and replay check, and orphan |
| 1669 | reaping were **not measured**. |
| 1670 | - 9.G: G1 (the original token, 7 min after first use) returned `same-ended-vm`, so the token window |
| 1671 | is at least 7 min. The planned 3 to 4 h point was not reached, because 7 and 8 were skipped. |
| 1672 | - 9.F again at 18:18:09Z, 6.5 min after VM_A ended: Get still answers TERMINATED, and the image |
| 1673 | list (9 VMs) still shows VM_A. |
| 1674 | - Estimate: 9 VMs, 0.10 VM-hours, $0.23. |
| 1675 | |
| 1676 | #### Attempt 4, teardown (section 10) and verification |
| 1677 | |
| 1678 | - 10.1: |
| 1679 | - No controller was running; settled (9 VMs, none live). |
| 1680 | - `image delete` at about 18:19:22Z; DELETING until 18:20:31Z, gone from the list at 18:20:48Z. |
| 1681 | - Versions `1.0` and `2.0` were confirmed deleted. |
| 1682 | - 10.2: |
| 1683 | - 0 interfaces before the delete. The connector delete started 18:20:59Z; `wait-gone` ok; 0 |
| 1684 | interfaces at 18:21:12Z (about 13 s). |
| 1685 | - No DELETE_FAILED, so the fallback was not needed. Interface cleanup was still not exercised: |
| 1686 | no interface ever appeared in the subnet, even with VMs running (U2 delete half still |
| 1687 | untested). |
| 1688 | - 10.3: deleted group `sg-0cb56fe86467e152b`, association `rtbassoc-092fc8d3d9525599f`, route |
| 1689 | table `rtb-0c24bb2e599df089d`, subnet `subnet-0e4cc358228df4994` and VPC `vpc-0048e6026eda29270`. |
| 1690 | Its defaults (`sg-0fcee04c7a190c689` with its two rules, `rtb-0f0e150517b1ef66e`, |
| 1691 | `acl-08cc47b20377a1a05`) were each confirmed gone by a filtered describe listing 0. |
| 1692 | - 10.4: the operator role (managed attachment and inline delete policy removed) and the build role |
| 1693 | were deleted; `get-role` gives `NoSuchEntity` for both. |
| 1694 | - 10.5: object and bucket deleted (bucket gone from the list at 18:22:28Z). |
| 1695 | - 10.6: log group deleted. 10.7: topic deleted (gone from the list at 18:22:43Z). |
| 1696 | - 10.8: |
| 1697 | - Unmatched values are settings, tokens, times and results only. Every resource ID has a |
| 1698 | `DELETED` line. |
| 1699 | - 9 VMs recorded, each confirmed ended. |
| 1700 | - Every intent has its confirmation (A3 and P4097 were confirmed refusals). |
| 1701 | - Tag index, by `run=1128-4ba61b` and by `purpose=equipo-hosted-dev`: only the deleted default |
| 1702 | group and its two rules, and the deleted connector. That is index lag; the direct reads show |
| 1703 | them gone. |
| 1704 | - Left in AWS: nothing. |
| 1705 | |
| 1706 | #### Attempt 4, spend (11.2) and VM lifetimes |
| 1707 | |
| 1708 | The provider's startedAt runs to the confirmed end (VMGONE), which is an upper bound. |
| 1709 | |
| 1710 | | VM | Source | Start | Confirmed end | Life | |
| 1711 | | --- | --- | --- | --- | --- | |
| 1712 | | microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 | A1 (also A2, E1, G1) | 18:10:24 | 18:11:40 | 75 s | |
| 1713 | | microvm-c1202e70-5391-3804-be8c-bca46b857d8c | P4096 | 18:11:07 | 18:11:20 | 13 s | |
| 1714 | | microvm-f0bb78f1-ce19-3bfb-84d3-30d771b46c5f | contract | 18:13:08 | 18:13:59 | 51 s | |
| 1715 | | microvm-fd98b38b-21f3-3291-bb56-9da85641cca7 | contract | 18:13:09 | 18:14:01 | 52 s | |
| 1716 | | microvm-352f0d76-82c3-3873-985e-774c9ac396d2 | contract | 18:13:09 | 18:13:52 | 43 s | |
| 1717 | | microvm-a9fcaa7f-74a1-3d91-8c81-58a587387199 | contract | 18:13:10 | 18:13:55 | 45 s | |
| 1718 | | microvm-084a6ecb-1fbd-304f-91b1-292c3595df7f | contract | 18:13:16 | 18:13:47 | 31 s | |
| 1719 | | microvm-bf348b8e-9b92-3296-8a16-05f39bbe7347 | contract | 18:13:32 | 18:13:57 | 25 s | |
| 1720 | | microvm-14ef54d4-957e-3570-bf6b-1f5395b284d7 | contract | 18:13:37 | 18:13:50 | 13 s | |
| 1721 | |
| 1722 | Total 348 s (0.10 VM-hours). 11.2 estimate: $0.23. That is about $0.02 of compute; the rest is |
| 1723 | fixed items (image storage minimum, builds, small items, pause cycles). Paul reads the bill. |
| 1724 | |
| 1725 | #### Attempt 4, FINDINGs (4) |
| 1726 | |
| 1727 | 1. 18:09:57Z, 5.6 "no network audit passed". This is a plan defect: the controller writes |
| 1728 | `network_audit_passed` only on a fail-to-pass transition (`reaper.go:747`). The metric showed |
| 1729 | `network_audit_passing 1`. |
| 1730 | 2. 18:15:04Z, contract `ChangedSpecConflicts` [known]: the `ValidationException` "The provided |
| 1731 | clientToken was used with different request parameters" is not mapped to `ErrConflict`. |
| 1732 | 3. 18:15:29Z, section 7 skipped (follows from 1). |
| 1733 | 4. 18:16:45Z, section 8 skipped (follows from 1). |
| 1734 | |
| 1735 | Journal (attempt 4, intents and controller lines omitted, as in 10.9): |
| 1736 | |
| 1737 | ``` |
| 1738 | RUN 1128-4ba61b start pin=bdf85fb70f26094b99241de3f1285de92a76a759 |
| 1739 | COLLISION-CHECKS clean |
| 1740 | CONFIRMED VPC vpc-0048e6026eda29270 |
| 1741 | CONFIRMED DEF_SG sg-0fcee04c7a190c689 |
| 1742 | CONFIRMED MAIN_RTB rtb-0f0e150517b1ef66e |
| 1743 | CONFIRMED DEF_ACL acl-08cc47b20377a1a05 |
| 1744 | CONFIRMED DEF_SG_RULES sgr-0114f9753b21dd97f sgr-054d5184b83c894d5 |
| 1745 | CONFIRMED SUBNET subnet-0e4cc358228df4994 |
| 1746 | CONFIRMED RTB rtb-0c24bb2e599df089d |
| 1747 | CONFIRMED RTB_ASSOC rtbassoc-092fc8d3d9525599f |
| 1748 | CONFIRMED SG sg-0cb56fe86467e152b |
| 1749 | CONFIRMED OPERATOR_ROLE_ARN arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1128-4ba61b-conn-op |
| 1750 | CONFIRMED OPERATOR_MANAGED_POLICY arn:aws:iam::aws:policy/AWSLambdaNetworkConnectorOperatorPolicy |
| 1751 | CONFIRMED OPERATOR_INLINE_POLICY t17-connector-eni-delete |
| 1752 | CONFIRMED CONN_ARN arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-2e892a59-0945-4534-89e9-c636b111fede |
| 1753 | CONFIRMED CONN_ID nc-2e892a59-0945-4534-89e9-c636b111fede |
| 1754 | CONFIRMED CONN_OPERATOR_POLICY managed AWSLambdaNetworkConnectorOperatorPolicy plus inline delete |
| 1755 | FACT connector create reply: {"State":"PENDING","Version":1,"VersionArn":"arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-2e892a59-0945-4534-89e9-c636b111fede:1","LatestVersion":null,"LatestVersionArn":null} |
| 1756 | TIMING connector-active |
| 1757 | CONFIRMED CONN_VERSION 1 |
| 1758 | CONFIRMED CONN_QARN arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-2e892a59-0945-4534-89e9-c636b111fede:1 |
| 1759 | FACT unqualified read: {"Version":null,"VersionArn":null,"LatestVersion":1,"LatestVersionArn":"arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-2e892a59-0945-4534-89e9-c636b111fede:1","ServerTime":"2026-11-28T18:03:38Z"} |
| 1760 | FACT connector versions: [{"Version":1,"VersionArn":"arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-2e892a59-0945-4534-89e9-c636b111fede:1","State":"ACTIVE"}] |
| 1761 | FACT interfaces in the VPC (2.4, connector ACTIVE): 0 |
| 1762 | CONFIRMED BUCKET_CREATED equipo-hosted-dev-t17-1128-4ba61b-640012953448 |
| 1763 | CONFIRMED LOG_GROUP_CREATED /aws/lambda-microvms/equipo-hosted-dev-t17-1128-4ba61b |
| 1764 | CONFIRMED BUILD_ROLE_ARN arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1128-4ba61b-build |
| 1765 | CONFIRMED DIGEST sha256:ca59e2a1a77f2e44e2b43429073fce30f663ed867d6e444d58fdb29ebaa938c4 |
| 1766 | CONFIRMED ARTIFACT_B64 ylnioad/LkTitDQpBz/OMPZj7YZ9bkRNWP2ynrqpOMQ= |
| 1767 | CONFIRMED ARTIFACT s3://equipo-hosted-dev-t17-1128-4ba61b-640012953448/t17/app.zip |
| 1768 | CONFIRMED BASE_ARN arn:aws:lambda:eu-west-1:aws:microvm-image:al2023-1 |
| 1769 | CONFIRMED BASE_VER 4 |
| 1770 | CONFIRMED BASE_VER_DOWN 3 |
| 1771 | CONFIRMED IMAGE_ARN arn:aws:lambda:eu-west-1:640012953448:microvm-image:equipo-hosted-dev-t17-1128-4ba61b |
| 1772 | CONFIRMED VER_SMALL 1.0 |
| 1773 | CONFIRMED BASE_VER_USED 4 |
| 1774 | FACT Small version: {"ImageVersion":"1.0","State":"SUCCESSFUL","Status":"ACTIVE","Tags":{"purpose":"equipo-hosted-dev","run":"1128-4ba61b"}} |
| 1775 | TIMING image-small-built |
| 1776 | CONFIRMED VER_LARGE 2.0 |
| 1777 | CONFIRMED TOPIC_ARN arn:aws:sns:eu-west-1:640012953448:equipo-hosted-dev-t17-1128-4ba61b-alerts |
| 1778 | FINDING no network audit passed |
| 1779 | CONFIRMED AUDIT_OK no |
| 1780 | CONFIRMED TOKEN_A equipo-hosted-dev-t17-1128-4ba61b-token-a |
| 1781 | CONFIRMED A1_BEFORE 2026-11-28T18:10:23.815Z |
| 1782 | VM microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 A1 2026-11-28T18:10:24.835Z |
| 1783 | CONFIRMED A1_AFTER 2026-11-28T18:10:24.878Z |
| 1784 | CONFIRMED VM_A microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 |
| 1785 | FIRST-VM-ID microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 (length 44) |
| 1786 | VM microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 A2 2026-11-28T18:10:24.835Z |
| 1787 | CONFIRMED A2_RESULT same-vm |
| 1788 | CONFIRMED A3_RESULT refused:ValidationException |
| 1789 | FACT A3 message: The provided clientToken was used with different request parameters. |
| 1790 | FACT interfaces in the VPC (9.B, VM_A running): 0 |
| 1791 | FACT VM_A echoes: {"IngressNetworkConnectors":["arn:aws:lambda:eu-west-1:aws:network-connector:aws-network-connector:NO_INGRESS"],"EgressNetworkConnectors":["arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-2e892a59-0945-4534-89e9-c636b111fede:1"],"MaximumDurationInSeconds":600,"ExecutionRoleArn":null,"IdlePolicy":null,"StartedAt":"2026-11-28T18:10:24.835Z"} |
| 1792 | CONFIRMED DATE_HEADER_get present |
| 1793 | FACT GetMicrovm Date header: 2026-11-28T18:10:40Z |
| 1794 | CONFIRMED DATE_HEADER_list not measured: livectl prints no metadata for lists |
| 1795 | CONFIRMED RESUME_ON_RUNNING accepted |
| 1796 | CONFIRMED SUSPEND_AT 2026-11-28T18:10:47.133Z |
| 1797 | CONFIRMED SUSPEND_ON_SUSPENDED accepted |
| 1798 | CONFIRMED RESUME_AT 2026-11-28T18:10:50.082Z |
| 1799 | CONFIRMED SECOND_RESUME accepted:after-first-resume |
| 1800 | VM microvm-c1202e70-5391-3804-be8c-bca46b857d8c P4096 2026-11-28T18:11:07.181Z |
| 1801 | VMGONE microvm-c1202e70-5391-3804-be8c-bca46b857d8c TERMINATED |
| 1802 | CONFIRMED PAYLOAD_4096 accepted |
| 1803 | CONFIRMED PAYLOAD_4097 refused:ValidationException |
| 1804 | FACT payload 4097 message: 1 validation error detected: Value at 'runHookPayload' failed to satisfy constraint: Member must have length less than or equal to 4096 |
| 1805 | VMGONE microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 TERMINATED |
| 1806 | CONFIRMED VM_A_ENDED 2026-11-28T18:11:40Z |
| 1807 | CONFIRMED TERMINATE_AGAIN ok |
| 1808 | VM microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 E1 2026-11-28T18:10:24.835Z |
| 1809 | CONFIRMED E1_RESULT same-ended-vm |
| 1810 | VM microvm-c1202e70-5391-3804-be8c-bca46b857d8c scan 2026-11-28T18:11:07.181Z |
| 1811 | VM microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 scan 2026-11-28T18:10:24.835Z |
| 1812 | SETTLED 2 recorded |
| 1813 | VISIBILITY VM_A TERMINATED since 2026-11-28T18:11:40Z |
| 1814 | PHASE 6-contract.json start 2026-11-28T18:13:07.063Z |
| 1815 | PHASE 6-contract.json end rc=1 |
| 1816 | FACT interfaces in the VPC (6.1, after the contract): 0 |
| 1817 | VM microvm-bf348b8e-9b92-3296-8a16-05f39bbe7347 scan 2026-11-28T18:13:32.148Z |
| 1818 | VM microvm-a9fcaa7f-74a1-3d91-8c81-58a587387199 scan 2026-11-28T18:13:10.542Z |
| 1819 | VM microvm-fd98b38b-21f3-3291-bb56-9da85641cca7 scan 2026-11-28T18:13:09.091Z |
| 1820 | VM microvm-f0bb78f1-ce19-3bfb-84d3-30d771b46c5f scan 2026-11-28T18:13:08.282Z |
| 1821 | VM microvm-084a6ecb-1fbd-304f-91b1-292c3595df7f scan 2026-11-28T18:13:16.431Z |
| 1822 | VM microvm-352f0d76-82c3-3873-985e-774c9ac396d2 scan 2026-11-28T18:13:09.752Z |
| 1823 | VM microvm-14ef54d4-957e-3570-bf6b-1f5395b284d7 scan 2026-11-28T18:13:37.597Z |
| 1824 | VMGONE microvm-084a6ecb-1fbd-304f-91b1-292c3595df7f TERMINATED |
| 1825 | VMGONE microvm-14ef54d4-957e-3570-bf6b-1f5395b284d7 TERMINATED |
| 1826 | VMGONE microvm-352f0d76-82c3-3873-985e-774c9ac396d2 TERMINATED |
| 1827 | VMGONE microvm-a9fcaa7f-74a1-3d91-8c81-58a587387199 TERMINATED |
| 1828 | VMGONE microvm-bf348b8e-9b92-3296-8a16-05f39bbe7347 TERMINATED |
| 1829 | VMGONE microvm-f0bb78f1-ce19-3bfb-84d3-30d771b46c5f TERMINATED |
| 1830 | VMGONE microvm-fd98b38b-21f3-3291-bb56-9da85641cca7 TERMINATED |
| 1831 | SETTLED 9 recorded |
| 1832 | FINDING contract TestLiveContract/ChangedSpecConflicts failed [known: refusal not mapped to ErrConflict]: contract.go:179: Launch with the same attempt and a new bootstrap = ("", awsjob: run: isolatedjob: invalid request: operation error Lambda Microvms: RunMicrovm, https response error StatusCode: 400, RequestID: 3120a8c3-bb78-4127-9a41-a268f4c66734, ValidationException: The provided clientToken was used with different request parameters.), want ErrConflict |
| 1833 | FINDING section 7 skipped: the 5.6 audit did not pass |
| 1834 | CONFIRMED SKIP_7 yes |
| 1835 | SETTLED 9 recorded |
| 1836 | FINDING section 8 skipped: the 5.6 audit did not pass |
| 1837 | CONFIRMED SKIP_8 yes |
| 1838 | VM microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 G1 2026-11-28T18:10:24.835Z |
| 1839 | CONFIRMED G1_RESULT same-ended-vm |
| 1840 | SETTLED 9 recorded |
| 1841 | VISIBILITY VM_A TERMINATED since 2026-11-28T18:11:40Z |
| 1842 | SETTLED 9 recorded |
| 1843 | DELETED microvm-image arn:aws:lambda:eu-west-1:640012953448:microvm-image:equipo-hosted-dev-t17-1128-4ba61b |
| 1844 | DELETED microvm-image-version arn:aws:lambda:eu-west-1:640012953448:microvm-image:equipo-hosted-dev-t17-1128-4ba61b:1.0 |
| 1845 | DELETED microvm-image-version arn:aws:lambda:eu-west-1:640012953448:microvm-image:equipo-hosted-dev-t17-1128-4ba61b:2.0 |
| 1846 | FACT interfaces in the VPC (10.2, before the connector delete): 0 |
| 1847 | DELETED connector arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-2e892a59-0945-4534-89e9-c636b111fede |
| 1848 | DELETED security-group sg-0cb56fe86467e152b |
| 1849 | DELETED route-table-association rtbassoc-092fc8d3d9525599f |
| 1850 | DELETED route-table rtb-0c24bb2e599df089d |
| 1851 | DELETED subnet subnet-0e4cc358228df4994 |
| 1852 | DELETED vpc vpc-0048e6026eda29270 |
| 1853 | DELETED vpc-default-security-group-rules sgr-0114f9753b21dd97f sgr-054d5184b83c894d5 |
| 1854 | DELETED vpc-default-security-group sg-0fcee04c7a190c689 |
| 1855 | DELETED vpc-main-route-table rtb-0f0e150517b1ef66e |
| 1856 | DELETED vpc-default-network-acl acl-08cc47b20377a1a05 |
| 1857 | DELETED iam-role arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1128-4ba61b-conn-op |
| 1858 | DELETED iam-inline-policy t17-connector-eni-delete |
| 1859 | DELETED iam-managed-attachment arn:aws:iam::aws:policy/AWSLambdaNetworkConnectorOperatorPolicy |
| 1860 | DELETED iam-role arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1128-4ba61b-build |
| 1861 | DELETED s3-object s3://equipo-hosted-dev-t17-1128-4ba61b-640012953448/t17/app.zip |
| 1862 | DELETED s3-bucket equipo-hosted-dev-t17-1128-4ba61b-640012953448 |
| 1863 | DELETED log-group /aws/lambda-microvms/equipo-hosted-dev-t17-1128-4ba61b |
| 1864 | DELETED sns-topic arn:aws:sns:eu-west-1:640012953448:equipo-hosted-dev-t17-1128-4ba61b-alerts |
| 1865 | ``` |
| 1866 | |
| 1867 | VM ledger (`vms.tsv`): |
| 1868 | |
| 1869 | ``` |
| 1870 | microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 A1 2026-11-28T18:10:24.835Z 2026-11-28T18:10:24.876Z |
| 1871 | microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 A2 2026-11-28T18:10:24.835Z 2026-11-28T18:10:25.906Z |
| 1872 | microvm-c1202e70-5391-3804-be8c-bca46b857d8c P4096 2026-11-28T18:11:07.181Z 2026-11-28T18:11:07.287Z |
| 1873 | microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 E1 2026-11-28T18:10:24.835Z 2026-11-28T18:11:42.363Z |
| 1874 | microvm-c1202e70-5391-3804-be8c-bca46b857d8c scan 2026-11-28T18:11:07.181Z 2026-11-28T18:11:43.399Z |
| 1875 | microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 scan 2026-11-28T18:10:24.835Z 2026-11-28T18:11:43.402Z |
| 1876 | microvm-bf348b8e-9b92-3296-8a16-05f39bbe7347 scan 2026-11-28T18:13:32.148Z 2026-11-28T18:13:45.292Z |
| 1877 | microvm-a9fcaa7f-74a1-3d91-8c81-58a587387199 scan 2026-11-28T18:13:10.542Z 2026-11-28T18:13:45.295Z |
| 1878 | microvm-fd98b38b-21f3-3291-bb56-9da85641cca7 scan 2026-11-28T18:13:09.091Z 2026-11-28T18:13:45.298Z |
| 1879 | microvm-f0bb78f1-ce19-3bfb-84d3-30d771b46c5f scan 2026-11-28T18:13:08.282Z 2026-11-28T18:13:45.301Z |
| 1880 | microvm-084a6ecb-1fbd-304f-91b1-292c3595df7f scan 2026-11-28T18:13:16.431Z 2026-11-28T18:13:45.304Z |
| 1881 | microvm-352f0d76-82c3-3873-985e-774c9ac396d2 scan 2026-11-28T18:13:09.752Z 2026-11-28T18:13:45.308Z |
| 1882 | microvm-14ef54d4-957e-3570-bf6b-1f5395b284d7 scan 2026-11-28T18:13:37.597Z 2026-11-28T18:13:45.313Z |
| 1883 | microvm-a8f71284-6226-3160-835a-8f2ba037b9f0 G1 2026-11-28T18:10:24.835Z 2026-11-28T18:17:00.602Z |
| 1884 | ``` |
| 1885 | |
| 1886 | ## Client token conflict mapping (2026-11-30, after attempt 4) |
| 1887 | |
| 1888 | Paul approved the fix on 2026-11-30. RunMicrovm's ValidationException "The |
| 1889 | provided clientToken was used with different request parameters." now maps |
| 1890 | to ErrConflict (op "run" only, message substring match); every other |
| 1891 | ValidationException keeps ErrInvalid. hostedctl treats ErrConflict and |
| 1892 | ErrInvalid from Launch alike (providerError, settle; both leave the intent |
| 1893 | waiting for Replay), so the outward change is the HTTP answer for that |
| 1894 | refusal: 409 "conflict" with its fixed message instead of 400 "invalid". |
| 1895 | |
| 1896 | - Red: TestClientTokenReuseConflicts/launch_token_reuse failed with |
| 1897 | "invalid request ... want isolatedjob: conflict" before the change. |
| 1898 | - Green: `go test -count=1 -run 'TestClientTokenReuseConflicts|TestErrorMapping' ./internal/isolatedjob/awsjob/` ok; |
| 1899 | `-run TestFakeContract ./internal/isolatedjob/`: ChangedSpecConflicts PASS (fake and late-visibility fake). |
| 1900 | - M1 drop the run-only condition: get_same_text fails. |
| 1901 | - M2 every ValidationException conflicts: TestErrorMapping/launch_ValidationException, |
| 1902 | payload_limit, other_validation, empty_message fail. |
| 1903 | - M3 remove the case: launch_token_reuse fails. |
| 1904 | - Astra round 1: APPROVED; its Minor (wrapped error, nil Message) folded in |
| 1905 | as two more rows. M4 replace errors.As with a direct type assertion: |
| 1906 | launch_token_reuse_wrapped fails. |
| 1907 | |
| 1908 | ## Task 17b live run (attempt 5) |
| 1909 | |
| 1910 | Plan `docs/superpowers/plans/2026-11-30-hosted-1a-task17b-live-plan.md` revision 1 (`78620c94`), |
| 1911 | code `bf29344a`, account `640012953448` (profile `kass`), `eu-west-1`. Paul's GO on discussion 46, |
| 1912 | 2026-11-30. Run `1130-b8103a4`, 2026-11-30 12:11:24Z (0.1) to 12:56:57Z (last 11.2). Every block |
| 1913 | ran as a script with the agent sandbox off; the long blocks and every controller start ran as |
| 1914 | `t17b-1130-b8103a4-*` systemd user units (R44, R45). No hard stop, no safe stop, no FINDING. |
| 1915 | |
| 1916 | ### Results by section |
| 1917 | |
| 1918 | - 0: code pin ok, livectl and awsjob offline tests ok; probe unit passed (only allowlisted names, |
| 1919 | `signal:TERM`); `640012953448` `user/remote-agent`; nothing tagged `purpose=equipo-hosted-dev`; |
| 1920 | collision checks clean. Estimate $0.04. |
| 1921 | - 1: VPC `vpc-044330dab8f4229a7` (DNS off, defaults tagged), subnet `subnet-0cff01091869c19d6`, |
| 1922 | route table `rtb-0096777df771ccfe1` (local only), group `sg-02a1457da3166e23b` (no rules). $0.04. |
| 1923 | - 2: operator role with the managed policy plus the scoped inline delete; connector |
| 1924 | `nc-bed72ef5-97cd-4de7-9f24-9ed16f559115` accepted on the first call, ACTIVE after about 4.4 min; |
| 1925 | version-1 read ACTIVE, no Elastic IP configuration, 0 interfaces. $0.04. |
| 1926 | - 3: bucket, log group (1-day retention), build role; base `al2023-1` version 4 (step-down 3 |
| 1927 | recorded, not used); image created first attempt; Small version `1.0` SUCCESSFUL ACTIVE in about |
| 1928 | 1.8 min, adapter fields match. $0.12. |
| 1929 | - 4: SNS topic `equipo-hosted-dev-t17-1130-b8103a4-alerts`, 0 subscriptions. $0.12. |
| 1930 | - 5: keys, configs (`small` only), both binaries; 5.6 audit-only start: `network_audit_passing 1`, |
| 1931 | `reap_last_error 0`, one `provider_bound` row for `aws:640012953448:eu-west-1`, no failure rows, |
| 1932 | 0 `network_audit_passed` rows, exit 0. `AUDIT_OK=yes`. $0.12. |
| 1933 | - 6: `ChangedSpecConflicts` PASS live; Get showed the new VM 74 ms after Launch; 1 VM settled. $0.13. |
| 1934 | - 7: sequence, crash and Replay all as expected (record lines below). $0.14. |
| 1935 | - 8: orphan stopped by the reaper at P+12:00, alert sent to SNS (record lines below). $0.18. |
| 1936 | - 10: image gone in about 1.5 min; connector deleted on the first try (no fallback), 0 interfaces |
| 1937 | before and after; network, roles, S3, log group and topic deleted, each proven by a direct read. |
| 1938 | 10.8: 4 VMs recorded, all confirmed ended; every resource has a `DELETED` line; the tag index |
| 1939 | still listed the default group, its two rules and the connector (all confirmed deleted: index |
| 1940 | lag). 10.9: no FINDING lines. |
| 1941 | |
| 1942 | ### Task 17b record (11.3) |
| 1943 | |
| 1944 | - ChangedSpecConflicts: `CONTRACT_CSC=pass` (the `5f6e3e65` mapping works live). |
| 1945 | - Sequence `task17-seq-7807b95d`: `timings: launch_call=267.257682ms to_running=50.255454856s drain_call=19.320561ms quiescent_call=19.669692ms suspend_call=106.056101ms to_suspended=1m0.468246276s resume=5.292139829s resume_calls=2 epoch=1 to_running_after_resume=37.169217ms stop_to_proof=5.30378646s stop_calls=2`; |
| 1946 | epoch 0 -> 1; job `stopped` with proof; audit rows launch_intent, launch_started, drain, |
| 1947 | quiescent, suspend_requested, suspend_settled, resume_prepared, resume_continued, |
| 1948 | resume_committed, stop_requested, stop_repeated, stop_proven. |
| 1949 | - Crash `task17-crash-11514c54`: the launch call saw the controller go away 278 ms in; exit status |
| 1950 | 137; crash VM `microvm-7571e222-fc51-3a46-8bbc-62f2c42c9c32` RUNNING; job `waiting` with no ref; |
| 1951 | `launch_intent` row. |
| 1952 | - Recover: the restarted unit's `env -i` argv had no crash switch; TestLiveCrashRecovery PASS; the |
| 1953 | job held the crash VM 55 s after the first read (Replay on the second reaper pass, 60 s after the |
| 1954 | first pass sighted the VM as `orphan_seen`); `replay_started`, `restart_rebased` (age 1m26s), |
| 1955 | `stop_requested`, `stop_proven`; job `stopped` holding the crash VM; 1 VM of the image started |
| 1956 | since the crash launch; no elapsed-unknown stop. |
| 1957 | - Orphan `microvm-06c9748f-8610-37fd-bad7-6987cfca3818`: planted 12:38:20Z (P); RUNNING to P+11:38, |
| 1958 | TERMINATED at P+12:00; controller stop at 12:50:15Z, `unclaimed_for=11m0.09s grace=10m0s`; |
| 1959 | `equipo_hosted_alerts_total{kind="orphan_stopped",result="sent"} 1` (first live SNS publish); |
| 1960 | no deferral; one `orphan_seen` and one `orphan_stopped` row for it. |
| 1961 | - Interfaces in the VPC: 0 at 2.4, 6.1, 7.2, 8.1 and 10.2. |
| 1962 | - 11.2 at the end: 4 VMs, 0.28 VM-hours, 1 image version, estimate $0.18. |
| 1963 | - FINDINGs: none. |
| 1964 | |
| 1965 | Journal (`journal-for-progress.txt`, INTENT and CONTROLLER lines left out): |
| 1966 | |
| 1967 | ```text |
| 1968 | UNIT t17b-1130-b8103a4-probe.service |
| 1969 | RUN 1130-b8103a4 start pin=bf29344a8b6832dff425aafc1337d4883f6a894f |
| 1970 | COLLISION-CHECKS clean |
| 1971 | CONFIRMED VPC vpc-044330dab8f4229a7 |
| 1972 | CONFIRMED DEF_SG sg-08e68aed5b8fff97c |
| 1973 | CONFIRMED MAIN_RTB rtb-0ddb9cb6cfcc3180d |
| 1974 | CONFIRMED DEF_ACL acl-0f6e3d54e365b155f |
| 1975 | CONFIRMED DEF_SG_RULES sgr-04267690ea065a725 sgr-0bf721ab0d646bfc1 |
| 1976 | CONFIRMED SUBNET subnet-0cff01091869c19d6 |
| 1977 | CONFIRMED RTB rtb-0096777df771ccfe1 |
| 1978 | CONFIRMED RTB_ASSOC rtbassoc-086bc50cdecc1b95f |
| 1979 | CONFIRMED SG sg-02a1457da3166e23b |
| 1980 | UNIT t17b-1130-b8103a4-2.1.service |
| 1981 | CONFIRMED OPERATOR_ROLE_ARN arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1130-b8103a4-conn-op |
| 1982 | CONFIRMED OPERATOR_MANAGED_POLICY arn:aws:iam::aws:policy/AWSLambdaNetworkConnectorOperatorPolicy |
| 1983 | CONFIRMED OPERATOR_INLINE_POLICY t17-connector-eni-delete |
| 1984 | CONFIRMED CONN_ARN arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-bed72ef5-97cd-4de7-9f24-9ed16f559115 |
| 1985 | CONFIRMED CONN_ID nc-bed72ef5-97cd-4de7-9f24-9ed16f559115 |
| 1986 | CONFIRMED CONN_OPERATOR_POLICY managed AWSLambdaNetworkConnectorOperatorPolicy plus inline delete |
| 1987 | FACT connector create reply: {"State":"PENDING","Version":1,"VersionArn":"arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-bed72ef5-97cd-4de7-9f24-9ed16f559115:1","LatestVersion":null,"LatestVersionArn":null} |
| 1988 | UNIT t17b-1130-b8103a4-2.3.service |
| 1989 | TIMING connector-active |
| 1990 | CONFIRMED CONN_VERSION 1 |
| 1991 | CONFIRMED CONN_QARN arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-bed72ef5-97cd-4de7-9f24-9ed16f559115:1 |
| 1992 | FACT unqualified read: {"Version":null,"VersionArn":null,"LatestVersion":1,"LatestVersionArn":"arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-bed72ef5-97cd-4de7-9f24-9ed16f559115:1","ServerTime":"2026-11-30T12:22:52Z"} |
| 1993 | FACT connector versions: [{"Version":1,"VersionArn":"arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-bed72ef5-97cd-4de7-9f24-9ed16f559115:1","State":"ACTIVE"}] |
| 1994 | FACT interfaces in the VPC (2.4, connector ACTIVE): 0 |
| 1995 | CONFIRMED BUCKET_CREATED equipo-hosted-dev-t17-1130-b8103a4-640012953448 |
| 1996 | CONFIRMED LOG_GROUP_CREATED /aws/lambda-microvms/equipo-hosted-dev-t17-1130-b8103a4 |
| 1997 | CONFIRMED BUILD_ROLE_ARN arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1130-b8103a4-build |
| 1998 | CONFIRMED DIGEST sha256:41f356359491246b3c6f87e3b799a9679f42066ff7a7de5267a813d4153066a7 |
| 1999 | CONFIRMED ARTIFACT_B64 QfNWNZSRJGs8b4fjt5mpZ59CBm/3p95SZ6gT1BUwZqc= |
| 2000 | CONFIRMED ARTIFACT s3://equipo-hosted-dev-t17-1130-b8103a4-640012953448/t17/app.zip |
| 2001 | CONFIRMED BASE_ARN arn:aws:lambda:eu-west-1:aws:microvm-image:al2023-1 |
| 2002 | CONFIRMED BASE_VER 4 |
| 2003 | CONFIRMED BASE_VER_DOWN 3 |
| 2004 | CONFIRMED IMAGE_ARN arn:aws:lambda:eu-west-1:640012953448:microvm-image:equipo-hosted-dev-t17-1130-b8103a4 |
| 2005 | CONFIRMED VER_SMALL 1.0 |
| 2006 | CONFIRMED BASE_VER_USED 4 |
| 2007 | UNIT t17b-1130-b8103a4-3.8.service |
| 2008 | FACT Small version: {"ImageVersion":"1.0","State":"SUCCESSFUL","Status":"ACTIVE","Tags":{"purpose":"equipo-hosted-dev","run":"1130-b8103a4"}} |
| 2009 | TIMING image-small-built |
| 2010 | CONFIRMED TOPIC_ARN arn:aws:sns:eu-west-1:640012953448:equipo-hosted-dev-t17-1130-b8103a4-alerts |
| 2011 | UNIT t17b-1130-b8103a4-ctl-audit-only.service |
| 2012 | FACT 5.6 metrics: equipo_hosted_store_readable 1 equipo_hosted_network_audit_passing 1 equipo_hosted_reap_last_error 0 equipo_hosted_reap_last_age_seconds 4.202161474 |
| 2013 | FACT network_audit_passed rows after a clean start: 0 (0 expected) |
| 2014 | CONFIRMED AUDIT_OK yes |
| 2015 | AUDIT passed before any launch |
| 2016 | UNIT t17b-1130-b8103a4-6.1.service |
| 2017 | PHASE 6-contract.json start 2026-11-30T12:29:05.161Z |
| 2018 | PHASE 6-contract.json end rc=0 |
| 2019 | VM microvm-abba1378-96f1-3024-acc8-3632a15120b8 6-contract.json phase:2026-11-30T12:29:05.161Z |
| 2020 | FACT interfaces in the VPC (6.1, after the contract subtest): 0 |
| 2021 | VM microvm-abba1378-96f1-3024-acc8-3632a15120b8 scan 2026-11-30T12:29:06.636Z |
| 2022 | VMGONE microvm-abba1378-96f1-3024-acc8-3632a15120b8 TERMINATED |
| 2023 | SETTLED 1 recorded |
| 2024 | CONFIRMED CONTRACT_CSC pass |
| 2025 | CONTRACT ChangedSpecConflicts pass |
| 2026 | UNIT t17b-1130-b8103a4-ctl-sequence.service |
| 2027 | UNIT t17b-1130-b8103a4-7.2.service |
| 2028 | CONFIRMED SEQ_ATTEMPT task17-seq-7807b95d |
| 2029 | PHASE 7.2-sequence.log start 2026-11-30T12:30:44.239Z |
| 2030 | PHASE 7.2-sequence.log end rc=0 |
| 2031 | VM microvm-6fc6be7c-70f5-3121-9b24-2379411f9d2a 7.2-sequence.log phase:2026-11-30T12:30:44.239Z |
| 2032 | FACT interfaces in the VPC (7.2, after the sequence): 0 |
| 2033 | VM microvm-6fc6be7c-70f5-3121-9b24-2379411f9d2a scan 2026-11-30T12:30:45.597Z |
| 2034 | VMGONE microvm-6fc6be7c-70f5-3121-9b24-2379411f9d2a TERMINATED |
| 2035 | SETTLED 2 recorded |
| 2036 | FACT sequence timings: launch_call=267.257682ms to_running=50.255454856s drain_call=19.320561ms quiescent_call=19.669692ms suspend_call=106.056101ms to_suspended=1m0.468246276s resume=5.292139829s resume_calls=2 epoch=1 to_running_after_resume=37.169217ms stop_to_proof=5.30378646s stop_calls=2 |
| 2037 | FACT sequence epoch 0 -> 1 |
| 2038 | UNIT t17b-1130-b8103a4-7.3.service |
| 2039 | CONFIRMED CRASH_ATTEMPT task17-crash-11514c54 |
| 2040 | CONFIRMED CRASH_START 2026-11-30T12:35:03 |
| 2041 | UNIT t17b-1130-b8103a4-ctl-crash.service |
| 2042 | PHASE 7.3-launch.log start 2026-11-30T12:35:15.489Z |
| 2043 | PHASE 7.3-launch.log end rc=0 |
| 2044 | VM microvm-7571e222-fc51-3a46-8bbc-62f2c42c9c32 controller phase:2026-11-30T12:35:03.850Z |
| 2045 | CONFIRMED CRASH_VM microvm-7571e222-fc51-3a46-8bbc-62f2c42c9c32 |
| 2046 | CRASH controller exited after launching microvm-7571e222-fc51-3a46-8bbc-62f2c42c9c32 |
| 2047 | UNIT t17b-1130-b8103a4-7.4.service |
| 2048 | UNIT t17b-1130-b8103a4-ctl-recover.service |
| 2049 | PHASE 7.4-recover.log start 2026-11-30T12:35:48.449Z |
| 2050 | PHASE 7.4-recover.log end rc=0 |
| 2051 | VM microvm-6fc6be7c-70f5-3121-9b24-2379411f9d2a 7.4-recover.log phase:2026-11-30T12:35:48.449Z |
| 2052 | VM microvm-7571e222-fc51-3a46-8bbc-62f2c42c9c32 7.4-recover.log phase:2026-11-30T12:35:48.449Z |
| 2053 | VM microvm-abba1378-96f1-3024-acc8-3632a15120b8 7.4-recover.log phase:2026-11-30T12:35:48.449Z |
| 2054 | VM microvm-7571e222-fc51-3a46-8bbc-62f2c42c9c32 scan 2026-11-30T12:35:16.745Z |
| 2055 | VMGONE microvm-7571e222-fc51-3a46-8bbc-62f2c42c9c32 TERMINATED |
| 2056 | SETTLED 3 recorded |
| 2057 | UNIT t17b-1130-b8103a4-ctl-orphan.service |
| 2058 | CONFIRMED ORPHAN_TOKEN equipo-hosted-dev-t17-1130-b8103a4-orphan |
| 2059 | CONFIRMED ORPHAN_PLANTED 2026-11-30T12:38:20Z |
| 2060 | VM microvm-06c9748f-8610-37fd-bad7-6987cfca3818 orphan 2026-11-30T12:38:27.592Z |
| 2061 | CONFIRMED ORPHAN_VM microvm-06c9748f-8610-37fd-bad7-6987cfca3818 |
| 2062 | FACT interfaces in the VPC (8.1, orphan planted): 0 |
| 2063 | UNIT t17b-1130-b8103a4-8.2.service |
| 2064 | ORPHAN stopped by the reaper at P+720s |
| 2065 | VM microvm-06c9748f-8610-37fd-bad7-6987cfca3818 controller phase:2026-11-30T12:38:14.087Z |
| 2066 | VMGONE microvm-06c9748f-8610-37fd-bad7-6987cfca3818 TERMINATED |
| 2067 | VM microvm-06c9748f-8610-37fd-bad7-6987cfca3818 scan 2026-11-30T12:38:27.592Z |
| 2068 | SETTLED 4 recorded |
| 2069 | UNIT t17b-1130-b8103a4-10.1.service |
| 2070 | SETTLED 4 recorded |
| 2071 | DELETED microvm-image arn:aws:lambda:eu-west-1:640012953448:microvm-image:equipo-hosted-dev-t17-1130-b8103a4 |
| 2072 | DELETED microvm-image-version arn:aws:lambda:eu-west-1:640012953448:microvm-image:equipo-hosted-dev-t17-1130-b8103a4:1.0 |
| 2073 | UNIT t17b-1130-b8103a4-10.2.service |
| 2074 | FACT interfaces in the VPC (10.2, before the connector delete): 0 |
| 2075 | DELETED connector arn:aws:lambda:eu-west-1:640012953448:network-connector:nc-bed72ef5-97cd-4de7-9f24-9ed16f559115 |
| 2076 | DELETED security-group sg-02a1457da3166e23b |
| 2077 | DELETED route-table-association rtbassoc-086bc50cdecc1b95f |
| 2078 | DELETED route-table rtb-0096777df771ccfe1 |
| 2079 | DELETED subnet subnet-0cff01091869c19d6 |
| 2080 | DELETED vpc vpc-044330dab8f4229a7 |
| 2081 | DELETED vpc-default-security-group-rules sgr-04267690ea065a725 sgr-0bf721ab0d646bfc1 |
| 2082 | DELETED vpc-default-security-group sg-08e68aed5b8fff97c |
| 2083 | DELETED vpc-main-route-table rtb-0ddb9cb6cfcc3180d |
| 2084 | DELETED vpc-default-network-acl acl-0f6e3d54e365b155f |
| 2085 | DELETED iam-role arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1130-b8103a4-conn-op |
| 2086 | DELETED iam-inline-policy t17-connector-eni-delete |
| 2087 | DELETED iam-managed-attachment arn:aws:iam::aws:policy/AWSLambdaNetworkConnectorOperatorPolicy |
| 2088 | DELETED iam-role arn:aws:iam::640012953448:role/equipo-hosted-dev-t17-1130-b8103a4-build |
| 2089 | DELETED s3-object s3://equipo-hosted-dev-t17-1130-b8103a4-640012953448/t17/app.zip |
| 2090 | DELETED s3-bucket equipo-hosted-dev-t17-1130-b8103a4-640012953448 |
| 2091 | DELETED log-group /aws/lambda-microvms/equipo-hosted-dev-t17-1130-b8103a4 |
| 2092 | DELETED sns-topic arn:aws:sns:eu-west-1:640012953448:equipo-hosted-dev-t17-1130-b8103a4-alerts |
| 2093 | ``` |
| 2094 | |
| 2095 | VM ledger (`vms.tsv`: ID, source, start, recorded at): |
| 2096 | |
| 2097 | ```text |
| 2098 | microvm-abba1378-96f1-3024-acc8-3632a15120b8 6-contract.json phase:2026-11-30T12:29:05.161Z 2026-11-30T12:29:07.449Z |
| 2099 | microvm-abba1378-96f1-3024-acc8-3632a15120b8 scan 2026-11-30T12:29:06.636Z 2026-11-30T12:29:09.661Z |
| 2100 | microvm-6fc6be7c-70f5-3121-9b24-2379411f9d2a 7.2-sequence.log phase:2026-11-30T12:30:44.239Z 2026-11-30T12:32:47.407Z |
| 2101 | microvm-6fc6be7c-70f5-3121-9b24-2379411f9d2a scan 2026-11-30T12:30:45.597Z 2026-11-30T12:33:19.130Z |
| 2102 | microvm-7571e222-fc51-3a46-8bbc-62f2c42c9c32 controller phase:2026-11-30T12:35:03.850Z 2026-11-30T12:35:17.086Z |
| 2103 | microvm-6fc6be7c-70f5-3121-9b24-2379411f9d2a 7.4-recover.log phase:2026-11-30T12:35:48.449Z 2026-11-30T12:36:50.675Z |
| 2104 | microvm-7571e222-fc51-3a46-8bbc-62f2c42c9c32 7.4-recover.log phase:2026-11-30T12:35:48.449Z 2026-11-30T12:36:50.677Z |
| 2105 | microvm-abba1378-96f1-3024-acc8-3632a15120b8 7.4-recover.log phase:2026-11-30T12:35:48.449Z 2026-11-30T12:36:50.680Z |
| 2106 | microvm-7571e222-fc51-3a46-8bbc-62f2c42c9c32 scan 2026-11-30T12:35:16.745Z 2026-11-30T12:36:52.060Z |
| 2107 | microvm-06c9748f-8610-37fd-bad7-6987cfca3818 orphan 2026-11-30T12:38:27.592Z 2026-11-30T12:38:27.705Z |
| 2108 | microvm-06c9748f-8610-37fd-bad7-6987cfca3818 controller phase:2026-11-30T12:38:14.087Z 2026-11-30T12:50:23.606Z |
| 2109 | microvm-06c9748f-8610-37fd-bad7-6987cfca3818 scan 2026-11-30T12:38:27.592Z 2026-11-30T12:50:31.805Z |
| 2110 | ``` |
| 2111 | |