Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import Foundation
@main struct PushDismissalLedgerChecks {
static func main() {
let suite = "orca.qa.dismissal." + UUID().uuidString
let defaults = UserDefaults(suiteName: suite)!
defer { defaults.removePersistentDomain(forName: suite) }
func payload(_ seq: Int, _ host: String = "qa-host", _ epoch: String = "qa-epoch", _ id: String = "qa-alert") -> [String: Any] {
["hostFingerprint": host, "notificationId": id, "notificationEpoch": epoch, "notificationSeq": seq]
}
func identity(_ seq: Int, _ host: String = "qa-host", _ epoch: String = "qa-epoch", _ id: String = "qa-alert") -> PushDismissalIdentity {
PushDismissalIdentity(payload(seq, host, epoch, id))!
}
let ledger = PushDismissalLedger(defaults: defaults)
ledger.remember(identity(2), now: 100)
ledger.remember(identity(1), now: 101)
let restored = PushDismissalLedger(defaults: defaults)
precondition(restored.contains(identity(1), now: 102))
precondition(restored.contains(identity(2), now: 102))
precondition(!restored.contains(identity(3), now: 102))
precondition(!restored.contains(identity(1, "other"), now: 102))
precondition(!restored.contains(identity(1, "qa-host", "other"), now: 102))
precondition(!restored.contains(identity(1, "qa-host", "qa-epoch", "other"), now: 102))
precondition(!restored.contains(identity(1), now: 86501))
precondition(PushDismissalIdentity(["hostFingerprint":"h", "notificationId":"n", "notificationEpoch":"e", "notificationSeq":true]) == nil)
precondition(restored.containsNotification(payload(1), now: 102))
precondition(!restored.containsNotification(payload(3), now: 102))
precondition(!restored.containsNotification(payload(1, "other"), now: 102))
precondition(!restored.containsNotification(payload(1, "qa-host", "other"), now: 102))
precondition(!restored.containsNotification(payload(1, "qa-host", "qa-epoch", "other"), now: 102))
precondition(!restored.containsNotification(["hostFingerprint": "qa-host"], now: 102))
for hosts in [1, 3] {
for index in 0..<520 {
ledger.remember(identity(2, "host-\(index % hosts)", "epoch-\(hosts)", "note-\(index)"), now: 200)
}
let reopened = PushDismissalLedger(defaults: defaults)
for index in [0, 1, 519] {
precondition(reopened.contains(identity(2, "host-\(index % hosts)", "epoch-\(hosts)", "note-\(index)"), now: 201))
precondition(!reopened.contains(identity(3, "host-\(index % hosts)", "epoch-\(hosts)", "note-\(index)"), now: 201))
precondition(!reopened.contains(identity(2, "host-\(index % hosts)", "epoch-\(hosts)", "note-\(index)"), now: 86600))
}
}
let batch = PushDismissalLedger(defaults: defaults)
batch.remember(identity(5, "batch"), now: 300)
batch.remember([identity(4, "batch"), identity(7, "batch", "qa-epoch", "b"), identity(6, "batch", "qa-epoch", "b"), identity(1, "batch", "qa-epoch", "c")], now: 300)
batch.remember([PushDismissalIdentity](), now: 301)
let batchReopened = PushDismissalLedger(defaults: defaults)
precondition(batchReopened.contains(identity(5, "batch"), now: 301))
precondition(!batchReopened.contains(identity(6, "batch"), now: 301))
precondition(batchReopened.contains(identity(7, "batch", "qa-epoch", "b"), now: 301))
precondition(!batchReopened.contains(identity(8, "batch", "qa-epoch", "b"), now: 301))
precondition(batchReopened.contains(identity(1, "batch", "qa-epoch", "c"), now: 301))
precondition(batchReopened.contains(identity(5, "batch"), now: 86699))
precondition(!batchReopened.contains(identity(5, "batch"), now: 86700))
print("Native persisted fence: restart, ordering, identity isolation, expiry and invalid sequence checks passed")
}
}