Skip to content

Stoic 0.4.0

Pre-release
Pre-release

Choose a tag to compare

@rvaccone rvaccone released this 18 Oct 04:45
· 125 commits to main since this release
Immutable release. Only release title and notes can be modified.

Stoic 0.4.0 adds downloads, sealed storage, and settings files people edit by hand, each driven by what Lodestar needed.

New libraries

  • StoicDownloads (design/23). Resumable, verified, durable file downloads. Bodies stream with backpressure on Apple platforms. Digests (SHA-256 or git-blob SHA-1) are checked while the bytes arrive, not in a second pass. A resume carries an If-Range validator, and the retry schedule resets whenever bytes arrive. The finished file is placed with fsync, rename and a directory sync. A DownloadBundle fetches several files and swaps the whole directory in at once, for models. It can adopt a partial file it did not write. Behind the Crypto trait.

  • StoicSealed (design/24). Encryption at rest with AES-256-GCM through swift-crypto:

    • A Keyring held in a KeyCustody.
    • Sealed files, SealedObjectFile for per-object keys, and SealedJournal, whose compaction can rotate the key so deleted records are gone for good.
    • Failures are told apart: tampered, torn, unknown key, not sealed.
    • The contract states the threat model plainly.

    Behind the Crypto trait, so adopters who do not enable it fetch nothing new.

  • StoicSealedKeychain. SecretStoreCustody, which turns any SecretStore (such as the Keychain) into a keyring's custody. A locked or refusing keychain is never read as an absent key.

Settings people edit by hand (design/18)

A .handEdited settings file is never moved or overwritten when it doesn't parse. The last good value is kept, and the problem carries a line and column. An update first reads the file again under a lock, so an edit made a moment ago is not lost.

New in this release:

  • Writing the file:
    • A canonical sparse layout, with caller-supplied key order and a file header.
    • materialize(), and replaceUnusableFile(...), which copies the broken file aside first.
  • Locking: blockingUpdate(waitingUpTo:) for synchronous callers that wait for the lock.
  • Watching the file: watch(debounce:) follows rename-saves.
  • Streams: changes(), with cause and source; problems().
  • Dialect:
    • Comments can be refused.
    • A repeated key is read last-wins with a warning, never as a reason to fall back to defaults.
  • JSON: JSONChange diffs and applies documents for undo history, plus path operations on JSONValue.

Store, Outbox and HTTP

  • PosixFileSystem(newFileMode:newDirectoryMode:) creates private files with no chmod window.
  • FileSystem.watchFile watches a file for changes.
  • Journals:
    • Journal.readOnlyReplay lets a second process read a journal without repairing it.
    • Journal.remove deletes a journal with its sidecars.
  • Outbox:
    • Breaking: a delivery closure now returns a DeliveryResult (.delivered, .discard(reason:), .keep).
    • Outbox.deliver(_:using:) awaits the outcome for one entry.
    • Undecodable entries and expiry each get a policy.
  • HTTP:
    • HTTPClient.stream streams a response body.
    • HTTPPolicy.singleAttempt makes one attempt and leaves retrying to the caller.
    • keyedConflictIsInProgress controls whether a 409 on a keyed request means "in progress".
  • KeychainSecretStore(loginKeychainService:) uses the macOS login keychain, for Developer ID apps without an application identifier.

Fixes

  • StoicTesting: a use-after-free in the simulation executor. An enqueue from another thread could signal an executor its simulation had already freed. Found under AddressSanitizer, with a deterministic regression test.
  • StoicTesting: TestClock.waitForSleepers works from XCTest without importing Testing.

Breaking changes

These are listed in api-breakage-allowlist.txt:

  • The Outbox delivery closure's result.
  • AtomicFile.Options.newFileMode is now optional (nil means the file system's mode).
  • New SettingsStore.UpdateError cases.