Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .agents/interfaces/.gitkeep
Empty file.
276 changes: 276 additions & 0 deletions .agents/interfaces/macos/Hashed.swiftinterface
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.4 (swiftlang-6.4.0.25.4 clang-2100.3.25.1)
// swift-module-flags: -target arm64-apple-macos12.0 -enable-objc-interop -language-mode 6 -O -enable-experimental-feature DebugDescriptionMacro -module-name Hashed -package-name swift_hashed
// swift-module-flags-ignorable: -formal-cxx-interoperability-mode=off -interface-compiler-version 6.4
@_exported import Equated
import Foundation
import Swift
import _Concurrency
import _StringProcessing
import _SwiftConcurrencyShims
extension Hashed::Hashed where Value : Swift::Error {
@inlinable public init(_ wrappedValue: Value) {
self.init(wrappedValue: wrappedValue)
}
@inlinable public init(wrappedValue: Value) {
self.init(
storedValue: .init(wrappedValue),
hasher: .localizedDescription
)
}
}
extension Hashed::Hashed where Value : Swift::Equatable, Value : Swift::Error {
@inlinable public init(_ wrappedValue: Value) {
self.init(wrappedValue: wrappedValue)
}
@inlinable public init(wrappedValue: Value) {
self.init(
storedValue: .init(wrappedValue),
hasher: .localizedDescription
)
}
}
extension Hashed::Hashed where Value : Swift::Error, Value : Swift::Hashable {
@inlinable public init(_ wrappedValue: Value) {
self.init(wrappedValue: wrappedValue)
}
@inlinable public init(wrappedValue: Value) {
self.init(
storedValue: .init(wrappedValue),
hasher: .defaultHashable
)
}
}
extension Hashed::Hashed where Value : Swift::Hashable {
@inlinable public init(wrappedValue: Value) {
self.init(
storedValue: .init(wrappedValue),
hasher: .defaultHashable
)
}
@inlinable public init(_ wrappedValue: Value) {
self.init(
storedValue: .init(wrappedValue),
hasher: .defaultHashable
)
}
}
extension Hashed::Hashed where Value : Swift::ExpressibleByNilLiteral {
@_disfavoredOverload @inlinable public init(by hasher: Hashed::Hashed<Value>.Hashed::Hasher = .uncheckedSendableDetectHashable()) {
self.init(
storedValue: .init(nil),
hasher: hasher
)
}
}
extension Hashed::Hashed where Value : Swift::ExpressibleByNilLiteral, Value : Swift::Sendable {
@_disfavoredOverload @inlinable public init(by hasher: Hashed::Hashed<Value>.Hashed::Hasher = .detectHashable()) {
self.init(
storedValue: .init(nil),
hasher: hasher
)
}
}
extension Hashed::Hashed where Value : Swift::ExpressibleByNilLiteral, Value : Swift::Hashable {
@inlinable public init() {
self.init(nil)
}
}
extension Hashed::Hashed where Value : Swift::ExpressibleByNilLiteral, Value : Swift::Hashable, Value : Swift::Sendable {
@inlinable public init() {
self.init(nil)
}
}
extension Hashed::Hashed where Value : Swift::Error, Value : Swift::ExpressibleByNilLiteral {
@inlinable public init() {
self.init(nil)
}
}
extension Hashed::Hashed where Value : Swift::Error, Value : Swift::ExpressibleByNilLiteral, Value : Swift::Hashable {
@inlinable public init() {
self.init(nil)
}
}
extension Hashed::Hashed where Value : Swift::Sendable {
@_disfavoredOverload @inlinable public init(wrappedValue: Value) {
self.init(
storedValue: .init(wrappedValue),
hasher: .detectHashable()
)
}
}
extension Hashed::Hashed {
@inlinable public init<T>(_: T.Type = T.self) where Value == T.Type {
self.init(
storedValue: Equated(T.self),
hasher: .typeID()
)
}
}
public protocol _HashedProtocol<Value> : Swift::Hashable {
associatedtype Value
var storedValue: Equated::Equated<Self.Value> { get set }
var hasher: Hashed::Hashed<Self.Value>.Hashed::Hasher { get set }
var wrappedValue: Self.Value { get set }
}
@propertyWrapper public struct Hashed<Value> : Hashed::_HashedProtocol {
@inlinable public static func == (lhs: Hashed::Hashed<Value>, rhs: Hashed::Hashed<Value>) -> Swift::Bool {
lhs.storedValue == rhs.storedValue
}
public var storedValue: Equated::Equated<Value>
public var hasher: Hashed::Hashed<Value>.Hashed::Hasher
public var wrappedValue: Value {
_read
_modify
}
public var projectedValue: Hashed::Hashed<Value> {
get
set
}
@inlinable public init(storedValue: Equated::Equated<Value>, hasher: Hashed::Hashed<Value>.Hashed::Hasher) {
self.storedValue = storedValue
self.hasher = hasher
}
@_disfavoredOverload @inlinable public init(_ wrappedValue: Value, by hasher: Hashed::Hashed<Value>.Hashed::Hasher) {
self.init(
storedValue: .init(wrappedValue),
hasher: hasher
)
}
@_disfavoredOverload @inlinable public init(wrappedValue: Value, by hasher: Hashed::Hashed<Value>.Hashed::Hasher = .uncheckedSendableDetectHashable()) {
self.init(
storedValue: .init(wrappedValue),
hasher: hasher
)
}
public func hash(into hasher: inout Swift::Hasher)
public var hashValue: Swift::Int {
get
}
}
extension Hashed::Hashed : Swift::Sendable where Value : Swift::Sendable {
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension Hashed::Hashed : Swift::Identifiable where Value : Swift::Identifiable {
@inlinable public var id: Value.ID {
get { wrappedValue.id }
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public typealias ID = Value.ID
}
extension Hashed::Hashed : Swift::Comparable where Value : Swift::Comparable {
@inlinable public static func < (lhs: Hashed::Hashed<Value>, rhs: Hashed::Hashed<Value>) -> Swift::Bool {
lhs.wrappedValue < rhs.wrappedValue
}
}
extension Hashed::Hashed : Swift::Error where Value : Swift::Error {
@inlinable public var localizedDescription: Swift::String {
get { wrappedValue.localizedDescription }
}
}
extension Hashed::Hashed : Foundation::LocalizedError where Value : Foundation::LocalizedError {
@inlinable public var errorDescription: Swift::String? {
get { wrappedValue.errorDescription }
}
@inlinable public var failureReason: Swift::String? {
get { wrappedValue.failureReason }
}
@inlinable public var recoverySuggestion: Swift::String? {
get { wrappedValue.recoverySuggestion }
}
@inlinable public var helpAnchor: Swift::String? {
get { wrappedValue.helpAnchor }
}
}
extension Hashed::Hashed {
public struct Hasher : Swift::Sendable {
@usableFromInline
internal let hash: @Sendable (Value, inout Swift::Hasher) -> Swift::Void
@usableFromInline
internal init(hash: @escaping @Sendable (Value, inout Swift::Hasher) -> Swift::Void)
@inlinable public func hash(_ value: Value, into hasher: inout Swift::Hasher) {
hash(value, &hasher)
}
@inlinable public func hashValue(for value: Value) -> Swift::Int {
var hasher = Swift.Hasher()
self.hash(value, into: &hasher)
return hasher.finalize()
}
}
}
extension Hashed::Hashed.Hashed::Hasher {
@inlinable public static var empty: Hashed::Hashed<Value>.Hashed::Hasher {
get {
.uncheckedSendable { _, _ in }
}
}
@inlinable public static func custom(_ hash: @escaping @Sendable (Value, inout Swift::Hasher) -> Swift::Void) -> Hashed::Hashed<Value>.Hashed::Hasher {
return .init(hash: hash)
}
public static var uncheckedSendableDump: Hashed::Hashed<Value>.Hashed::Hasher {
get
}
}
extension Hashed::Hashed.Hashed::Hasher where Value : Swift::Sendable {
public static var dump: Hashed::Hashed<Value>.Hashed::Hasher {
get
}
}
extension Hashed::Hashed.Hashed::Hasher where Value : AnyObject {
public static var objectID: Hashed::Hashed<Value>.Hashed::Hasher {
get
}
}
extension Hashed::Hashed.Hashed::Hasher where Value : Swift::Error {
@inlinable public static var localizedDescription: Hashed::Hashed<Value>.Hashed::Hasher {
get {
.property(\.localizedDescription)
}
}
}
extension Hashed::Hashed.Hashed::Hasher where Value : Swift::Hashable {
@inlinable public static var defaultHashable: Hashed::Hashed<Value>.Hashed::Hasher {
get {
return .uncheckedSendable { value, hasher in
value.hash(into: &hasher)
}
}
}
}
extension Hashed::Hashed.Hashed::Hasher {
public static func uncheckedSendableDetectHashable(fallback: Hashed::Hashed<Value>.Hashed::Hasher = .uncheckedSendableDump) -> Hashed::Hashed<Value>.Hashed::Hasher
}
extension Hashed::Hashed.Hashed::Hasher where Value : Swift::Sendable {
public static func detectHashable(fallback: Hashed::Hashed<Value>.Hashed::Hasher = .dump) -> Hashed::Hashed<Value>.Hashed::Hasher
}
extension Hashed::Hashed.Hashed::Hasher {
public static func hashable<T>(_ other: T) -> Hashed::Hashed<Value>.Hashed::Hasher where T : Swift::Hashable, T : Swift::Sendable
public static func uncheckedSendable<T>(_ other: T) -> Hashed::Hashed<Value>.Hashed::Hasher where T : Swift::Hashable
}
extension Hashed::Hashed.Hashed::Hasher {
@inlinable public static func property<Property>(_ scope: @escaping @Sendable (Value) -> Property) -> Hashed::Hashed<Value>.Hashed::Hasher where Property : Swift::Hashable, Property : Swift::Sendable {
return .custom { scope($0).hash(into: &$1) }
}
}
extension Hashed::Hashed.Hashed::Hasher {
@inlinable public static func uncheckedSendable<Property>(_ scope: @escaping (Value) -> Property) -> Hashed::Hashed<Value>.Hashed::Hasher where Property : Swift::Hashable {
return .uncheckedSendable { scope($0).hash(into: &$1) }
}
}
extension Hashed::Hashed.Hashed::Hasher {
@inlinable public static func uncheckedSendable(_ hash: @escaping (Value, inout Swift::Hasher) -> Swift::Void) -> Hashed::Hashed<Value>.Hashed::Hasher {
let hash = _UncheckedSendable(action: hash)
return .custom(hash.callAsFunction)
}
@usableFromInline
internal struct _UncheckedSendable : @unchecked Swift::Sendable {
private var action: (Value, inout Swift::Hasher) -> Swift::Void
@usableFromInline
internal init(action: @escaping (Value, inout Swift::Hasher) -> Swift::Void)
@usableFromInline
internal func callAsFunction(_ value: Value, into hasher: inout Swift::Hasher)
}
}
extension Hashed::Hashed.Hashed::Hasher {
public static func typeID<T>() -> Hashed::Hashed<Value>.Hashed::Hasher where Value == T.Type
}
120 changes: 120 additions & 0 deletions .github/workflows/generate-swiftinterface.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Generate Swift interface
run-name: Generate ${{ inputs.platform }} interfaces

on:
workflow_dispatch:
inputs:
platform:
description: Normalized platform name (macos, ios, linux, windows, wasi, ...)
required: true
type: string
target_branch:
description: Branch that receives the generated-interface PR (defaults to the dispatched branch)
required: false
default: ""
type: string
workflow_call:
inputs:
platform:
required: true
type: string
target_branch:
required: true
type: string

permissions:
contents: write
pull-requests: write

jobs:
generate:
name: Generate ${{ inputs.platform }}
runs-on: ${{ (inputs.platform == 'linux' || inputs.platform == 'wasi') && 'ubuntu-latest' || inputs.platform == 'windows' && 'windows-latest' || 'macos-latest' }}
env:
GH_TOKEN: ${{ github.token }}
INPUT_TARGET_BRANCH: ${{ inputs.target_branch }}
PLATFORM: ${{ inputs.platform }}
steps:
- name: Validate request
shell: bash
run: |
if [[ ! "$PLATFORM" =~ ^[a-z0-9][a-z0-9._-]*$ ]]; then
echo "Platform must be a normalized lowercase directory name: $PLATFORM" >&2
exit 1
fi

- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ inputs.target_branch != '' && inputs.target_branch || github.ref_name }}

- name: Set up Swift outside Xcode
if: runner.os != 'macOS'
uses: SwiftyLab/setup-swift@v1
with:
swift-version: "6"
sdks: ${{ inputs.platform == 'wasi' && 'wasm' || '' }}

- name: Prepare generation branch
shell: bash
run: |
target_branch="${INPUT_TARGET_BRANCH:-$GITHUB_REF_NAME}"
interface_branch="automation/swiftinterfaces/$GITHUB_RUN_ID/$PLATFORM"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git switch -C "$interface_branch"
echo "TARGET_BRANCH=$target_branch" >> "$GITHUB_ENV"
echo "INTERFACE_BRANCH=$interface_branch" >> "$GITHUB_ENV"

- name: Select WASI SDK
if: inputs.platform == 'wasi'
shell: bash
run: |
swift_sdk="$(swift sdk list | sed -nE '/(_wasm|wasi)/ { s/^[[:space:]]*([^[:space:]]+).*/\1/p; q; }')"
if [[ -z "$swift_sdk" ]]; then
echo "No installed WASI Swift SDK was found" >&2
swift sdk list >&2 || true
exit 1
fi
echo "SWIFT_SDK=$swift_sdk" >> "$GITHUB_ENV"

- name: Generate interface
shell: bash
run: |
interface_dir=".agents/interfaces/$PLATFORM"
if [[ -d "$interface_dir" ]]; then
find "$interface_dir" -maxdepth 1 -type f -name '*.swiftinterface' -delete
fi
if [[ -n "${SWIFT_SDK:-}" ]]; then
make swiftinterface platform="$PLATFORM" swift_sdk="$SWIFT_SDK"
else
make swiftinterface platform="$PLATFORM"
fi

- name: Commit and push interface
id: commit
shell: bash
run: |
git add --all -- ".agents/interfaces/$PLATFORM"
if git diff --cached --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No $PLATFORM interface changes" >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
git commit -m "Update $PLATFORM Swift interfaces"
git push --force-with-lease --set-upstream origin "$INTERFACE_BRANCH"
echo "changed=true" >> "$GITHUB_OUTPUT"

- name: Open platform PR
if: steps.commit.outputs.changed == 'true'
shell: bash
run: |
pr_url="$(gh pr list --state open --base "$TARGET_BRANCH" --head "$INTERFACE_BRANCH" --json url --jq '.[0].url')"
if [[ -z "$pr_url" ]]; then
pr_url="$(gh pr create \
--base "$TARGET_BRANCH" \
--head "$INTERFACE_BRANCH" \
--title "chore: update $PLATFORM Swift interfaces" \
--body "Generated from \`$TARGET_BRANCH\` by workflow run $GITHUB_RUN_ID. Merge this PR into the aggregation branch after reviewing the platform-specific API snapshot.")"
fi
echo "$pr_url" >> "$GITHUB_STEP_SUMMARY"
Loading
Loading