Repository navigation
Commit a938217
authored
fix(cli): end a remote lease allocated by a materialization that never persisted (#4135)
* refactor(move): split connection-runtime by ownership seam
connection-runtime.ts crossed the 1,000-line architecture-debt line. Split it
along the seams the file already had, with no behavior change:
- connection-lease-policy.ts: which lease a provider's connection allocates, its
TTL, and the id it names a new lease with
- connection-lease-transaction.ts: the acquisition transaction — resolve the
device, allocate or renew the lease, bind it to the record, and release it
- connection-metro-runtime.ts: the deferred Metro runtime preparation the record
carries, and the tunnel teardown
- connection-previous-lease.ts: releasing the lease a reconnect replaces, with
the previous endpoint's own credential
- connection-runtime.ts: the materialization that sequences those three and
persists the record
Importers now name the module that owns each declaration.
* fix(cli): end a remote lease allocated by a materialization that never persisted
`materializeRemoteConnectionForCommand` allocated a lease and then could fail
before `persistMaterializedConnection` wrote the record that would name it — a
rejected `prepareConnectedMetro` was the live path. The only release path ran
when the state-file write itself failed, so the new lease was neither saved nor
ended: no record named it, so `disconnect` could not reach it, and it held the
device until its TTL lapsed.
The call now owns a lease it allocated until persistence transfers ownership,
and every earlier exit ends it. A lease the call renewed was already named by
the stored record, so this path never releases it — disconnect still does.
The failure that ended the command stays the thrown error. A release that failed
too is recorded beside it as typed secondary evidence under `details.leaseRollback`
(ADR 0010 as amended by ADR 0019), never in its place.
* chore(gates): drop the legacy line cap for connection-runtime.ts
The split left every module under the 1,000-line limit, so the 1,019-line legacy
cap for connection-runtime.ts has no subject.
* fix(cli): end only a lease this command created, from allocation to the durable record
The independent review found three ownership gaps in the lease rollback.
- The daemon now answers each lease_allocate with whether its request created
the lease (reused on the wire, Lease.created on the client). A run's repeat
allocation gets the run's existing lease back, and that lease belongs to
whoever holds it: this path ends only a lease the daemon says it created.
- A lease enters the new ledger the moment allocation returns, before any
later validation or binding can fail, so a platform conflict after a
successful allocation can no longer leak it. Binding cleanup consumes the
same ownership, so a lease is never released twice.
- Ownership transfers at the durable session record, not at the whole write:
the commit-point callback runs between the record and the active-session
pointer, so a pointer failure leaves a named lease to disconnect.
A release that did not end the lease keeps it owned, and the failure path
reports it beside the command's own failure as typed details.leaseRollback.
* fix(cli): stop the keyless-lease fallback when its first lease survives, and document created correctly
The round-2 review found two gaps.
- The keyless-lease fallback released the daemon-granted lease and ignored
whether that release ended it. A throwing or refused release left the first
lease owned by no durable record while the fallback allocated a replacement
that became the connection. The fallback now requires a confirmed retirement;
otherwise the command fails with PROXY_LEASE_RETIREMENT_FAILED, the ledger
keeps the lease, and the failure path retries the release and reports it as
details.leaseRollback beside the refusal.
- The published JSDoc on Lease.created stated the mapping backwards; it now
reads true = created by this allocation, false = an existing lease, absent =
the daemon did not answer. website/docs/docs/client-api.md describes the
field and the release guard: release only when created is true, and a
missing answer is not permission to release.
* fix: preserve older daemon allocation binding and simplify lease rollback
* test: assert fallback lease binds the selected device
* fix: report spec lease rollback failures in one typed shape
* fix: release discarded allocations without creation evidence
* docs: limit lease release retry to discarded allocations
* fix: scope allocation evidence and protect the lease ledger1 parent a42bc35 commit a938217
29 files changed
Lines changed: 2050 additions & 914 deletions
File tree
- packages
- client/src
- __tests__
- contracts/src
- daemon/src/sessions/handlers
- __tests__
- remote/src
- src
- __tests__
- cli
- commands
- __tests__
- connection
- website/docs/docs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | 66 | | |
68 | 67 | | |
69 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
132 | 166 | | |
133 | 167 | | |
134 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
83 | 116 | | |
84 | 117 | | |
85 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
145 | 151 | | |
146 | 152 | | |
147 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
248 | 254 | | |
249 | 255 | | |
250 | 256 | | |
251 | 257 | | |
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
| 261 | + | |
255 | 262 | | |
256 | 263 | | |
257 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
70 | 87 | | |
71 | 88 | | |
72 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 10 | + | |
| 11 | + | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
| |||
0 commit comments