oficina / base Public

Merge branch 'fix/release-build' into main

Merge branch 'fix/release-build' into main

Works around a Swift 6.4.2 release-optimiser crash (CopyPropagation on
AskModel.listen's task closure) that stopped the Mac app's release build.
Behaviour unchanged; check-native.sh 107 tests and hub CI green.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 0f244141db951d13c68ff46b5936007716de5cd0 parent 3bcec1eparent ffd4fd5
1 file changed, +36 −25
  • native/apple/Sources/BaseKit/Ask/AskModel.swift +36 −25

CI passed — run details

CI log
=== build ===
CGO_ENABLED=0 go build ./...
=== vet ===
go vet ./...
=== fmt-check ===
=== staticcheck ===
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 ./...
=== govulncheck ===
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
No vulnerabilities found.
=== gitleaks ===
9:56PM INF Unknown SCM platform. Use --platform to include links in findings. host=amadan.net
9:56PM INF 1 commits scanned.
9:56PM INF scanned ~2380772 bytes (2.38 MB) in 235ms
9:56PM INF no leaks found
=== budget ===
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size
budget size: 22 directories within budget
=== script-test ===
scripts/prepare-apps_test.sh
ok   releases lookup failure stops before ship
ok   app owned elsewhere stops the script
ok   apps listing failure stops before create
ok   ambiguous release dir is refused
ok   explicit version resolves the ambiguity
ok   releases match is exact, not substring
ok   shipped version is only promoted, existing app not created
ok   fresh account creates, ships, promotes to edge, enables
ok   failing promote stops the script
ok   ship is retried while uploads are rate limited
all passed
hack/fonts_test.sh
fonts_test: ok
=== test ===
go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -count=1 ./...

receipt: test step 8.135s against a 60s target (the gate's other steps are not in this figure)
receipt: 16 packages ran, 0 cached, 6 without tests, 0 failed
receipt: slow package 6.803s amadan.net/oficina/base/internal/webtest
receipt: slow package 1.366s amadan.net/oficina/base/internal/issuer
receipt: slow package 640ms amadan.net/oficina/base/internal/operations
receipt: slow package 263ms amadan.net/oficina/base/internal/consumer
receipt: slow package 189ms amadan.net/oficina/base/internal/e2e
receipt: slow test 1.52s amadan.net/oficina/base/internal/webtest TestHomeDoesNotWaitOnAStalledSnapshot
receipt: slow test 1.09s amadan.net/oficina/base/internal/webtest TestAskZoneIsToldOnce
receipt: slow test 1.03s amadan.net/oficina/base/internal/issuer TestAuthorizeSignsForInstalledApp
receipt: slow test 520ms amadan.net/oficina/base/internal/operations TestOperationsRefusals
receipt: slow test 300ms amadan.net/oficina/base/internal/issuer TestAuthorizeRefusals
=== native ===
strings: copy review's strings.json is not here (git-ignored); its comparison skipped
strings: 119 in the catalog, 116 used
worktree-lib_test: ok
diff --git a/native/apple/Sources/BaseKit/Ask/AskModel.swift b/native/apple/Sources/BaseKit/Ask/AskModel.swift
index ef3f312..e676daa 100644
--- a/native/apple/Sources/BaseKit/Ask/AskModel.swift
+++ b/native/apple/Sources/BaseKit/Ask/AskModel.swift
@@ -229,32 +229,43 @@ import SwiftUI
let epoch = generation
stream = Task { [weak self] in
var failures = 0
+ // Each round holds the model only while it runs; between rounds
+ // the task keeps no strong reference. (A helper method rather than
+ // `guard let self` in this loop: Swift 6.4.2's release optimiser
+ // crashes on the latter, in CopyPropagation.)
while !Task.isCancelled {
- guard let self, self.generation == epoch else { return }
- let client = self.client
- do {
- try await client.events(after: self.cursor, onRetry: { [weak self] ms in await self?.retryAfter(ms) }) { [weak self] event, id in
- await self?.receive(event, id: id, epoch: epoch)
- }
- failures = 0
- guard self.generation == epoch, self.phase.chatting else { return }
- try? await Task.sleep(for: .milliseconds(max(500, self.retryMilliseconds)))
- } catch {
- guard self.generation == epoch, !Task.isCancelled else { return }
- switch error as? BaseAPIError ?? .badResponse {
- case .unauthenticated:
- return
- case .offline:
- failures = min(failures + 1, 6)
- try? await Task.sleep(for: .seconds(2 * failures))
- guard self.generation == epoch, !Task.isCancelled else { return }
- self.reload()
- return
- default:
- self.reload()
- return
- }
- }
+ guard let model = self else { return }
+ guard await model.streamRound(epoch: epoch, failures: &failures) else { return }
+ }
+ }
+ }
+
+ /// One connection to the event stream. Returns whether to keep going.
+ private func streamRound(epoch: Int, failures: inout Int) async -> Bool {
+ guard generation == epoch else { return false }
+ let client = self.client
+ do {
+ try await client.events(after: cursor, onRetry: { [weak self] ms in await self?.retryAfter(ms) }) { [weak self] event, id in
+ await self?.receive(event, id: id, epoch: epoch)
+ }
+ failures = 0
+ guard generation == epoch, phase.chatting else { return false }
+ try? await Task.sleep(for: .milliseconds(max(500, retryMilliseconds)))
+ return true
+ } catch {
+ guard generation == epoch, !Task.isCancelled else { return false }
+ switch error as? BaseAPIError ?? .badResponse {
+ case .unauthenticated:
+ return false
+ case .offline:
+ failures = min(failures + 1, 6)
+ try? await Task.sleep(for: .seconds(2 * failures))
+ guard generation == epoch, !Task.isCancelled else { return false }
+ reload()
+ return false
+ default:
+ reload()
+ return false
}
}
}