Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Verify pinned specification
run: grep -q "0e0290eda4eb66792cf215f4ba52f0f95ebbd357" SPEC_BASELINE.md
run: grep -q "91631e59e9afa1d053c5a62775ca4adb35286a22" SPEC_BASELINE.md
- name: Test deterministic core
run: swift test --skip CameraPlacementTests --skip CameraFairnessTests --parallel --num-workers 1
- name: Test camera placement
Expand All @@ -43,7 +43,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Verify pinned specification
run: grep -q "0e0290eda4eb66792cf215f4ba52f0f95ebbd357" SPEC_BASELINE.md
run: grep -q "91631e59e9afa1d053c5a62775ca4adb35286a22" SPEC_BASELINE.md
- name: Test runtime audit wiring guards
run: python3 -B scripts/test_runtime_audit_guards.py
- name: Test spec-parity checkout isolation
Expand Down
41 changes: 31 additions & 10 deletions App/AudioEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ final class AudioEngine {
}
}

private let engine = AVAudioEngine()
private let voices: [PitchedVoice]
private var engine: AVAudioEngine?
private var voices: [PitchedVoice] = []
private var pcmBuffers: [String: AVAudioPCMBuffer] = [:]
private let effectPool = EffectVoicePool()

Expand Down Expand Up @@ -65,22 +65,25 @@ final class AudioEngine {
private(set) var interrupted = false
private var suspended = false
private var cueTasks: [UUID: Task<Void, Never>] = [:]
private static var sessionConfigured = false
private var dropTask: Task<Void, Never>?
private var interruptionObserver: NSObjectProtocol?
nonisolated(unsafe) private var interruptionObserver: NSObjectProtocol?

init() {
let catalog = try? AssetCatalog.bundled()
deliveredPaths = catalog?.deliveredAudioPaths ?? [:]
deliveredGainDb = catalog?.deliveredAudioGainDb ?? [:]
voices = (0..<Self.voiceCapacity).map { _ in PitchedVoice() }
for voice in voices {
voice.attach(to: engine, format: Self.canonicalFormat)
}
configureSession()
prepareHaptics()
observeInterruptions()
}

deinit {
if let observer = interruptionObserver {
NotificationCenter.default.removeObserver(observer)
}
}

/// Pre-decodes delivered short SFX into RAM once before play begins so the
/// first hit of each cue never touches disk on a 60 Hz frame.
func preloadEffects() {
Expand All @@ -92,14 +95,30 @@ final class AudioEngine {
}

private func configureSession() {
guard !Self.sessionConfigured else { return }
Self.sessionConfigured = true
let session = AVAudioSession.sharedInstance()
try? session.setCategory(.ambient, mode: .default, options: [.mixWithOthers])
try? session.setActive(true)
}

@discardableResult
private func ensureVoiceGraphAttached() -> AVAudioEngine {
if let engine { return engine }
let created = AVAudioEngine()
let pool = (0..<Self.voiceCapacity).map { _ in PitchedVoice() }
for voice in pool {
voice.attach(to: created, format: Self.canonicalFormat)
}
voices = pool
engine = created
return created
}

private func startEngineIfNeeded() {
guard !engine.isRunning else { return }
try? engine.start()
let eng = ensureVoiceGraphAttached()
guard !eng.isRunning else { return }
try? eng.start()
}

private func prepareHaptics() {
Expand Down Expand Up @@ -164,7 +183,8 @@ final class AudioEngine {
private func suspendPlayback() {
cancelDeferredWork()
effectPool.stopAll()
if engine.isRunning { engine.pause() }
for voice in voices { voice.stop() }
if let engine, engine.isRunning { engine.pause() }
for player in musicPlayers.values { player.stop() }
ambience?.stop()
ambience = nil
Expand Down Expand Up @@ -243,6 +263,7 @@ final class AudioEngine {
func reset() {
cancelDeferredWork()
effectPool.stopAll()
for voice in voices { voice.stop() }
for player in musicPlayers.values { player.stop() }
musicPlayers = [:]
ambience?.stop()
Expand Down
12 changes: 7 additions & 5 deletions SPEC_BASELINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Status: PINNED
| Identity | Value |
|---|---|
| Specification repository | `Zero-State-LLC/SS-specs` |
| Specification commit | `0e0290eda4eb66792cf215f4ba52f0f95ebbd357` |
| Ruleset | `ss-rules-014` |
| Content | `civic-seam-content-009` |
| Arena | `civic-seam-arena-004` |
| Specification commit | `91631e59e9afa1d053c5a62775ca4adb35286a22` |
| Ruleset | `ss-rules-015` |
| Content | `civic-seam-content-010` |
| Arena | `civic-seam-arena-005` |
| Replay schema | `runtime-kernel-001` |
| Diagnostic receipt | `run-receipt-002` |
| Visual language | `visual-language-002` |
Expand Down Expand Up @@ -97,4 +97,6 @@ D-121 adoption (SS-specs #91): the Victorian Vendor mine is a clear-filled ring

D-123 / T1061 candidate adoption (SS-specs #115, owner intent accepted 2026-11-15 23:18 UTC): new diagnostic writes declare `run-receipt-002`, preserve Camera/objective evidence and record the selected upgrade as exact ID plus `upgrades-003`. Historical v1 schema and archived bytes remain unchanged. Archive reads report identity recognition without conformance certification; unsupported writer identities fail before side effects. RC-001–RC-008 govern verification. Ruleset, content, arena, replay schema and golden gameplay digests are unchanged. The asset catalog pin field alone follows the specification commit. **Merge SS-specs #115 before this dependent runtime change.** Candidate implementation is not main adoption, defect closure or physical acceptance.

D-122 / D-124 / D-125 / D-126 Stage-1 candidate adoption (`feat/stage1-civic-seam-25d-specs` at `0e0290eda4eb66792cf215f4ba52f0f95ebbd357`): `visual-language-002`, `clip-metadata-002`, `presentation-assets-004`, `arena-presentation-001`, and canonical `run-shell-001` (`PAUSED` overlay, RS-043–RS-046). Ruleset (`ss-rules-014`), content (`civic-seam-content-009`), arena (`civic-seam-arena-004`), replay schema (`runtime-kernel-001`), and all golden fixtures remain byte-frozen with zero digest drift.
D-122 / D-124 / D-125 / D-126 Stage-1 candidate adoption (`SS-specs #116` at `0e0290eda4eb66792cf215f4ba52f0f95ebbd357`): `visual-language-002`, `clip-metadata-002`, `presentation-assets-004`, `arena-presentation-001`, and canonical `run-shell-001` (`PAUSED` overlay, RS-043–RS-046).

D-127 Stage-2 candidate adoption (`SS-specs #117` at `91631e59e9afa1d053c5a62775ca4adb35286a22`): ruleset `ss-rules-015`, content `civic-seam-content-010` (`combat-content-010`), and arena `civic-seam-arena-005`. Blackout-gated Extraction pursuit (`xp-01..04`, up to 4 aware `autonomousInformant` pursuers when `< 8/8` Cameras destroyed, silent at `8/8` Network Blackout), `improperSearchDaemon` `CaptainPath` corner Dijkstra routing, Authority Court rear barrier lock-in (`gate-mc-forward` + `gate-elite-forward`), armed/1-tick-from-arming Vendor mine `LETHAL THREAT` warning, and calibrated `SURGICAL` (`damageTaken <= 75`) and `SWIFT` (`elapsedTicks < 17100`) medals. `ss-rules-014` replays fail closed; all four golden fixtures and complete-run vectors are refreshed for `ss-rules-015`.
2 changes: 1 addition & 1 deletion Sources/SurveillanceCore/Arena/ArenaManifest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public struct ArenaManifest: Equatable, Sendable, Codable {
}

public static func bundled() throws -> ArenaManifest {
let data = BundledResource.data(name: "civic-seam-arena-004", subdirectory: "contracts")
let data = BundledResource.data(name: "civic-seam-arena-005", subdirectory: "contracts")
return try ArenaLoader.decodeAndValidate(data)
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/SurveillanceCore/ContractVersions.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
public enum ContractVersions {
public static let specificationCommit = "0e0290eda4eb66792cf215f4ba52f0f95ebbd357"
public static let ruleset = "ss-rules-014"
public static let content = "civic-seam-content-009"
public static let arena = "civic-seam-arena-004"
public static let specificationCommit = "91631e59e9afa1d053c5a62775ca4adb35286a22"
public static let ruleset = "ss-rules-015"
public static let content = "civic-seam-content-010"
public static let arena = "civic-seam-arena-005"
public static let replaySchema = "runtime-kernel-001"
public static let runReceipt = "run-receipt-002"
public static let upgrades = "upgrades-003"
Expand Down
2 changes: 1 addition & 1 deletion Sources/SurveillanceCore/Contracts/CombatContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public struct CombatContent: Equatable, Sendable {
public var player: PlayerDamageSpec

public static func bundled() -> CombatContent {
let data = BundledResource.data(name: "combat-content-009", subdirectory: "contracts")
let data = BundledResource.data(name: "combat-content-010", subdirectory: "contracts")
return try! decode(data)
}

Expand Down
40 changes: 36 additions & 4 deletions Sources/SurveillanceCore/Enemies/EnemySystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public enum EnemySystem {
player: player,
tick: tick,
content: content,
bounds: bounds,
allocator: &allocator,
projectiles: &projectiles,
mines: &mines,
Expand Down Expand Up @@ -136,6 +137,7 @@ public enum EnemySystem {
player: PlayerBody,
tick: UInt64,
content: CombatContent,
bounds: AABB,
allocator: inout EntityAllocator,
projectiles: inout [ProjectileBody],
mines: inout [MineBody],
Expand Down Expand Up @@ -293,7 +295,14 @@ public enum EnemySystem {
}

case .improperSearchDaemon:
stepDaemon(&enemy, player: player, speed: speed, playerDamage: &playerDamage)
stepDaemon(
&enemy,
player: player,
speed: speed,
bounds: bounds,
solids: solids,
playerDamage: &playerDamage
)

case .algorithmicModerate:
break
Expand All @@ -304,12 +313,21 @@ public enum EnemySystem {
_ enemy: inout EnemyBody,
player: PlayerBody,
speed: Int64,
bounds: AABB,
solids: [(id: String, box: AABB)],
playerDamage: inout Int
) {
if enemy.stateTicks > 0 {
switch enemy.state {
case .pursue:
enemy.velocity = Steering.toward(enemy.position, player.position, speedPerTickQ8: speed)
let target = CaptainPath.approach(
from: enemy.position,
to: player.position,
radius: enemy.radius,
bounds: bounds,
solids: solids
).point
enemy.velocity = Steering.toward(enemy.position, target, speedPerTickQ8: speed)
case .dash:
break
default:
Expand All @@ -326,7 +344,14 @@ public enum EnemySystem {
case .queryTelegraph:
enemy.state = .queryResolve
enemy.stateTicks = 0
stepDaemon(&enemy, player: player, speed: speed, playerDamage: &playerDamage)
stepDaemon(
&enemy,
player: player,
speed: speed,
bounds: bounds,
solids: solids,
playerDamage: &playerDamage
)
case .queryResolve:
playerDamage += DaemonQuery.damage(playerPosition: player.position, markers: enemy.queryMarkers)
enemy.state = .dashTelegraph
Expand All @@ -347,7 +372,14 @@ public enum EnemySystem {
default:
enemy.state = .pursue
enemy.stateTicks = 120
enemy.velocity = Steering.toward(enemy.position, player.position, speedPerTickQ8: speed)
let target = CaptainPath.approach(
from: enemy.position,
to: player.position,
radius: enemy.radius,
bounds: bounds,
solids: solids
).point
enemy.velocity = Steering.toward(enemy.position, target, speedPerTickQ8: speed)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public struct EnvironmentLibrary: Equatable, Sendable {
// MARK: - Loading

public static func bundled() throws -> EnvironmentLibrary {
let presentation = try SpecBundle.contract(ContractVersions.presentationAssets)
let presentation = SpecBundle.contract(ContractVersions.presentationAssets)
guard let root = try? JSONSerialization.jsonObject(with: presentation) as? [String: Any] else {
throw AssetCatalogError.invalidJSON
}
Expand Down
17 changes: 17 additions & 0 deletions Sources/SurveillanceCore/Presentation/LethalWarning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ public enum LethalWarning {
let solids = state.liveSolids
if bossTelegraphWouldExhaust(state, solids: solids) { return true }
let percent = state.content.player.damageTakenPercent
for mine in state.mines where mine.lifeRemaining > 1 {
if mine.armed {
let reach = Int64(mine.radius + PlayerBody.radiusUnits) * Q8.scale
if state.player.position.distanceSquared(to: mine.position) <= reach * reach,
Comment on lines +69 to +70

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match the armed-mine warning to the actual damage radius

When the Player is outside the mine radius but within one Player radius of its edge, this branch reports a lethal threat even though the mine cannot damage them. resolvePlayerDeathAndContact in Simulation.swift checks the Player's center against mine.radius only, without adding PlayerBody.radiusUnits. A probe with 1 Integrity, an armed radius-42 mine, and a center distance of 50 returns a lethal warning while the following stationary tick leaves Integrity unchanged. Use the same radius predicate as damage resolution, as the one-tick-from-arming branch already does, to avoid false warnings that preempt the Lockdown and Extraction cards.

Useful? React with 👍 / 👎.

wouldExhaust(mine.damage, state: state, percent: percent)
{
return true
}
} else if mine.armRemaining == 1 {
let r = Int64(mine.radius) * Q8.scale
if state.player.position.distanceSquared(to: mine.position) <= r * r,
wouldExhaust(mine.damage, state: state, percent: percent)
{
return true
}
}
}
for enemy in state.enemies where enemy.alive && !enemy.isUnaware {
switch enemy.archetype {
case .improperSearchDaemon where enemy.state == .queryTelegraph:
Expand Down
18 changes: 10 additions & 8 deletions Sources/SurveillanceCore/Presentation/Medals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ public enum Medal: String, CaseIterable, Codable, Equatable, Hashable, Sendable
/// The name the run card, the title, and Share print.
public var name: String { rawValue.uppercased() }

/// § 12 `SWIFT`: under 5:30, that is, under 19,800 ticks.
public static let swiftTicks: UInt64 = 19_800
/// § 12 `SWIFT` (D-127): under 4:45, that is, under 17,100 ticks.
public static let swiftTicks: UInt64 = 17_100
/// § 12 `SURGICAL` (D-127): at most 75 cumulative Integrity lost across the run.
public static let surgicalMaxDamageTaken: Int = 75
}

/// Folds a run's events, tick by tick, into what the medals need to know.
Expand Down Expand Up @@ -79,21 +81,21 @@ public struct MedalTracker: Equatable, Sendable {
case .ghost: state.exposure.quietApproach
case .shadow: !patrolAlertedBeforeMobA
case .blackout: state.networkBlackout
case .surgical: Self.surgical(integrity: state.player.integrity, max: state.player.maxIntegrity)
case .surgical: Self.surgical(damageTaken: state.player.damageTaken)
case .swift: Self.swift(ticks: state.tick)
}
}
}

/// § 12 `SWIFT`: elapsed time under 5:30.
/// § 12 `SWIFT` (D-127): elapsed time under 4:45 (17,100 ticks).
public static func swift(ticks: UInt64) -> Bool {
ticks < Medal.swiftTicks
}

/// § 12 `SURGICAL`: at least half of `player.integrity` (RS-020: 74 of
/// 150 is not, 75 is).
public static func surgical(integrity: Int, max: Int) -> Bool {
integrity * 2 >= max
/// § 12 `SURGICAL` (D-127): cumulative Integrity lost across the run is at
/// most `Medal.surgicalMaxDamageTaken` (75; RS-020: 76 is not, 75 is).
public static func surgical(damageTaken: Int, maxAllowed: Int = Medal.surgicalMaxDamageTaken) -> Bool {
damageTaken <= maxAllowed
}

/// Replays `commands` from `seed` and derives the medals: what RS-022
Expand Down
8 changes: 4 additions & 4 deletions Sources/SurveillanceCore/Resources/SPEC_PIN.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SS-specs commit 0e0290eda4eb66792cf215f4ba52f0f95ebbd357
ruleset ss-rules-014
content civic-seam-content-009
arena civic-seam-arena-004
SS-specs commit 91631e59e9afa1d053c5a62775ca4adb35286a22
ruleset ss-rules-015
content civic-seam-content-010
arena civic-seam-arena-005
replaySchema runtime-kernel-001
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"schemaVersion": "arena-presentation-001",
"arenaVersion": "civic-seam-arena-004",
"arenaVersion": "civic-seam-arena-005",
"projection": {
"groundRotationDegrees": 45,
"groundYScale": 0.5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"const": "arena-presentation-001"
},
"arenaVersion": {
"const": "civic-seam-arena-004"
"const": "civic-seam-arena-005"
},
"projection": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schemaVersion": "asset-catalog-001",
"legacyRepository": "scrimshawlife-ctrl/Surveillance-Survivor",
"legacyCommit": "3b20d88d6a6e1fe8f07f45f581359d371fa65d98",
"specificationCommit": "0e0290eda4eb66792cf215f4ba52f0f95ebbd357",
"specificationCommit": "91631e59e9afa1d053c5a62775ca4adb35286a22",
"entries": [
{
"admissionDecision": "excluded",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"cameraPlacementVersion": "camera-placement-001",
"arenaVersion": "civic-seam-arena-004",
"arenaVersion": "civic-seam-arena-005",
"sockets": [
{
"socketId": "cam-z02-a",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"required": ["cameraPlacementVersion", "arenaVersion", "sockets"],
"properties": {
"cameraPlacementVersion": {"const": "camera-placement-001"},
"arenaVersion": {"const": "civic-seam-arena-004"},
"arenaVersion": {"const": "civic-seam-arena-005"},
"sockets": {
"type": "array",
"minItems": 18,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"schemaVersion": "arena-manifest-001",
"arenaVersion": "civic-seam-arena-004",
"arenaVersion": "civic-seam-arena-005",
"cellSizeUnits": 64,
"gridSizeCells": {
"width": 36,
Expand Down
Loading
Loading