From 1f606841a479616e197742c5580ce12cf527ff55 Mon Sep 17 00:00:00 2001 From: Daniel Meyer Date: Fri, 27 Nov 2026 20:10:05 -0800 Subject: [PATCH 1/4] Stage 2 (D-127): ss-rules-015 gameplay, Daemon Dijkstra, Court lock-in, mine warning, and medal calibration --- .github/workflows/ci.yml | 4 +- SPEC_BASELINE.md | 10 +- .../Arena/ArenaManifest.swift | 2 +- .../SurveillanceCore/ContractVersions.swift | 8 +- .../Contracts/CombatContent.swift | 2 +- .../Enemies/EnemySystem.swift | 40 +- .../Presentation/LethalWarning.swift | 17 + .../Presentation/Medals.swift | 18 +- .../SurveillanceCore/Resources/SPEC_PIN.txt | 8 +- .../contracts/arena-presentation-001.json | 2 +- .../arena-presentation-001.schema.json | 2 +- .../contracts/asset-catalog-001.json | 2 +- .../contracts/camera-placement-001.json | 2 +- .../camera-placement-001.schema.json | 2 +- ...ena-004.json => civic-seam-arena-005.json} | 2 +- ....json => civic-seam-arena-005.schema.json} | 4 +- .../contracts/combat-content-009.json | 49 -- .../contracts/combat-content-010.json | 457 ++++++++++++++++++ .../contracts/run-receipt-002.schema.json | 2 +- .../contracts/runtime-kernel-001.json | 6 +- .../Resources/contracts/versions.json | 10 +- .../fixtures/complete-run-vectors-001.json | 2 +- .../fixtures/kernel-vectors-001.json | 2 +- .../Resources/fixtures/replay-matrix-001.json | 2 +- .../Resources/fixtures/replay-smoke-001.json | 6 +- .../World/IsolatedKernel.swift | 8 +- .../SurveillanceCore/World/Simulation.swift | 74 +++ .../SurveillanceCore/World/WorldTypes.swift | 4 +- .../ArenaReachabilityTests.swift | 6 +- .../AudioDeliveryTests.swift | 2 +- .../AwarenessTests.swift | 4 +- .../CombatContentFailClosedTests.swift | 2 +- .../CompleteRunVectorTests.swift | 1 + .../ExtractionCountdownTests.swift | 70 +++ .../HeatReinforcementTests.swift | 2 +- .../LethalWarningTests.swift | 9 +- Tests/SurveillanceCoreTests/MedalTests.swift | 12 +- .../PacingProbe/DeviceSittingQA.swift | 4 +- .../ReadabilityFinishTests.swift | 4 +- .../ReplayMatrixTests.swift | 1 + Tests/SurveillanceCoreTests/ReplayTests.swift | 4 +- .../TransitPatrolTests.swift | 2 +- .../UpgradesContractParityTests.swift | 2 +- 43 files changed, 744 insertions(+), 128 deletions(-) rename Sources/SurveillanceCore/Resources/contracts/{civic-seam-arena-004.json => civic-seam-arena-005.json} (99%) rename Sources/SurveillanceCore/Resources/contracts/{civic-seam-arena-004.schema.json => civic-seam-arena-005.schema.json} (98%) delete mode 100644 Sources/SurveillanceCore/Resources/contracts/combat-content-009.json create mode 100644 Sources/SurveillanceCore/Resources/contracts/combat-content-010.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b7d18b4..ed6db6bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Verify pinned specification - run: grep -q "0e0290eda4eb66792cf215f4ba52f0f95ebbd357" SPEC_BASELINE.md + run: grep -q "bcef0c31eafdaa8aa2f2eb2577a57c8664bf7b70" SPEC_BASELINE.md - name: Test deterministic core run: swift test --skip CameraPlacementTests --skip CameraFairnessTests --parallel --num-workers 1 - name: Test camera placement @@ -43,7 +43,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Verify pinned specification - run: grep -q "0e0290eda4eb66792cf215f4ba52f0f95ebbd357" SPEC_BASELINE.md + run: grep -q "bcef0c31eafdaa8aa2f2eb2577a57c8664bf7b70" SPEC_BASELINE.md - name: Test runtime audit wiring guards run: python3 -B scripts/test_runtime_audit_guards.py - name: Test spec-parity checkout isolation diff --git a/SPEC_BASELINE.md b/SPEC_BASELINE.md index 3033e3b5..d84a11c5 100644 --- a/SPEC_BASELINE.md +++ b/SPEC_BASELINE.md @@ -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 | `bcef0c31eafdaa8aa2f2eb2577a57c8664bf7b70` | +| 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` | @@ -97,4 +97,4 @@ 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 (`feat/stage1-civic-seam-25d-specs` at `bcef0c31eafdaa8aa2f2eb2577a57c8664bf7b70`): `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. diff --git a/Sources/SurveillanceCore/Arena/ArenaManifest.swift b/Sources/SurveillanceCore/Arena/ArenaManifest.swift index af228011..f0b9af08 100644 --- a/Sources/SurveillanceCore/Arena/ArenaManifest.swift +++ b/Sources/SurveillanceCore/Arena/ArenaManifest.swift @@ -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) } diff --git a/Sources/SurveillanceCore/ContractVersions.swift b/Sources/SurveillanceCore/ContractVersions.swift index b5e779da..36693101 100644 --- a/Sources/SurveillanceCore/ContractVersions.swift +++ b/Sources/SurveillanceCore/ContractVersions.swift @@ -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 = "bcef0c31eafdaa8aa2f2eb2577a57c8664bf7b70" + 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" diff --git a/Sources/SurveillanceCore/Contracts/CombatContent.swift b/Sources/SurveillanceCore/Contracts/CombatContent.swift index bef251bd..ef356448 100644 --- a/Sources/SurveillanceCore/Contracts/CombatContent.swift +++ b/Sources/SurveillanceCore/Contracts/CombatContent.swift @@ -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) } diff --git a/Sources/SurveillanceCore/Enemies/EnemySystem.swift b/Sources/SurveillanceCore/Enemies/EnemySystem.swift index fc10495d..3b345d85 100644 --- a/Sources/SurveillanceCore/Enemies/EnemySystem.swift +++ b/Sources/SurveillanceCore/Enemies/EnemySystem.swift @@ -104,6 +104,7 @@ public enum EnemySystem { player: player, tick: tick, content: content, + bounds: bounds, allocator: &allocator, projectiles: &projectiles, mines: &mines, @@ -136,6 +137,7 @@ public enum EnemySystem { player: PlayerBody, tick: UInt64, content: CombatContent, + bounds: AABB, allocator: inout EntityAllocator, projectiles: inout [ProjectileBody], mines: inout [MineBody], @@ -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 @@ -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: @@ -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 @@ -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) } } diff --git a/Sources/SurveillanceCore/Presentation/LethalWarning.swift b/Sources/SurveillanceCore/Presentation/LethalWarning.swift index f55febe1..57f071d9 100644 --- a/Sources/SurveillanceCore/Presentation/LethalWarning.swift +++ b/Sources/SurveillanceCore/Presentation/LethalWarning.swift @@ -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, + 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: diff --git a/Sources/SurveillanceCore/Presentation/Medals.swift b/Sources/SurveillanceCore/Presentation/Medals.swift index abb93607..2b9fd064 100644 --- a/Sources/SurveillanceCore/Presentation/Medals.swift +++ b/Sources/SurveillanceCore/Presentation/Medals.swift @@ -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. @@ -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 diff --git a/Sources/SurveillanceCore/Resources/SPEC_PIN.txt b/Sources/SurveillanceCore/Resources/SPEC_PIN.txt index 46d5b346..7271517f 100644 --- a/Sources/SurveillanceCore/Resources/SPEC_PIN.txt +++ b/Sources/SurveillanceCore/Resources/SPEC_PIN.txt @@ -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 bcef0c31eafdaa8aa2f2eb2577a57c8664bf7b70 +ruleset ss-rules-015 +content civic-seam-content-010 +arena civic-seam-arena-005 replaySchema runtime-kernel-001 diff --git a/Sources/SurveillanceCore/Resources/contracts/arena-presentation-001.json b/Sources/SurveillanceCore/Resources/contracts/arena-presentation-001.json index 6a8197d8..08beafb1 100644 --- a/Sources/SurveillanceCore/Resources/contracts/arena-presentation-001.json +++ b/Sources/SurveillanceCore/Resources/contracts/arena-presentation-001.json @@ -1,6 +1,6 @@ { "schemaVersion": "arena-presentation-001", - "arenaVersion": "civic-seam-arena-004", + "arenaVersion": "civic-seam-arena-005", "projection": { "groundRotationDegrees": 45, "groundYScale": 0.5, diff --git a/Sources/SurveillanceCore/Resources/contracts/arena-presentation-001.schema.json b/Sources/SurveillanceCore/Resources/contracts/arena-presentation-001.schema.json index 61779a59..8aaa4ce8 100644 --- a/Sources/SurveillanceCore/Resources/contracts/arena-presentation-001.schema.json +++ b/Sources/SurveillanceCore/Resources/contracts/arena-presentation-001.schema.json @@ -20,7 +20,7 @@ "const": "arena-presentation-001" }, "arenaVersion": { - "const": "civic-seam-arena-004" + "const": "civic-seam-arena-005" }, "projection": { "type": "object", diff --git a/Sources/SurveillanceCore/Resources/contracts/asset-catalog-001.json b/Sources/SurveillanceCore/Resources/contracts/asset-catalog-001.json index 1d4cf218..d2a41343 100644 --- a/Sources/SurveillanceCore/Resources/contracts/asset-catalog-001.json +++ b/Sources/SurveillanceCore/Resources/contracts/asset-catalog-001.json @@ -2,7 +2,7 @@ "schemaVersion": "asset-catalog-001", "legacyRepository": "scrimshawlife-ctrl/Surveillance-Survivor", "legacyCommit": "3b20d88d6a6e1fe8f07f45f581359d371fa65d98", - "specificationCommit": "0e0290eda4eb66792cf215f4ba52f0f95ebbd357", + "specificationCommit": "bcef0c31eafdaa8aa2f2eb2577a57c8664bf7b70", "entries": [ { "admissionDecision": "excluded", diff --git a/Sources/SurveillanceCore/Resources/contracts/camera-placement-001.json b/Sources/SurveillanceCore/Resources/contracts/camera-placement-001.json index 8ee2a552..70459d13 100644 --- a/Sources/SurveillanceCore/Resources/contracts/camera-placement-001.json +++ b/Sources/SurveillanceCore/Resources/contracts/camera-placement-001.json @@ -1,6 +1,6 @@ { "cameraPlacementVersion": "camera-placement-001", - "arenaVersion": "civic-seam-arena-004", + "arenaVersion": "civic-seam-arena-005", "sockets": [ { "socketId": "cam-z02-a", diff --git a/Sources/SurveillanceCore/Resources/contracts/camera-placement-001.schema.json b/Sources/SurveillanceCore/Resources/contracts/camera-placement-001.schema.json index 1374935f..05d749be 100644 --- a/Sources/SurveillanceCore/Resources/contracts/camera-placement-001.schema.json +++ b/Sources/SurveillanceCore/Resources/contracts/camera-placement-001.schema.json @@ -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, diff --git a/Sources/SurveillanceCore/Resources/contracts/civic-seam-arena-004.json b/Sources/SurveillanceCore/Resources/contracts/civic-seam-arena-005.json similarity index 99% rename from Sources/SurveillanceCore/Resources/contracts/civic-seam-arena-004.json rename to Sources/SurveillanceCore/Resources/contracts/civic-seam-arena-005.json index ff89f41c..c5f1c528 100644 --- a/Sources/SurveillanceCore/Resources/contracts/civic-seam-arena-004.json +++ b/Sources/SurveillanceCore/Resources/contracts/civic-seam-arena-005.json @@ -1,6 +1,6 @@ { "schemaVersion": "arena-manifest-001", - "arenaVersion": "civic-seam-arena-004", + "arenaVersion": "civic-seam-arena-005", "cellSizeUnits": 64, "gridSizeCells": { "width": 36, diff --git a/Sources/SurveillanceCore/Resources/contracts/civic-seam-arena-004.schema.json b/Sources/SurveillanceCore/Resources/contracts/civic-seam-arena-005.schema.json similarity index 98% rename from Sources/SurveillanceCore/Resources/contracts/civic-seam-arena-004.schema.json rename to Sources/SurveillanceCore/Resources/contracts/civic-seam-arena-005.schema.json index fc8792d5..90ab335d 100644 --- a/Sources/SurveillanceCore/Resources/contracts/civic-seam-arena-004.schema.json +++ b/Sources/SurveillanceCore/Resources/contracts/civic-seam-arena-005.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://github.com/scrimshawlife-ctrl/SS-specs/contracts/civic-seam-arena-004.schema.json", + "$id": "https://github.com/scrimshawlife-ctrl/SS-specs/contracts/civic-seam-arena-005.schema.json", "title": "Civic Seam Arena Manifest", "type": "object", "required": [ @@ -30,7 +30,7 @@ "const": "arena-manifest-001" }, "arenaVersion": { - "const": "civic-seam-arena-004" + "const": "civic-seam-arena-005" }, "cellSizeUnits": { "const": 64 diff --git a/Sources/SurveillanceCore/Resources/contracts/combat-content-009.json b/Sources/SurveillanceCore/Resources/contracts/combat-content-009.json deleted file mode 100644 index ae08db40..00000000 --- a/Sources/SurveillanceCore/Resources/contracts/combat-content-009.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "schemaVersion": "combat-content-009", - "contracts": {"enemies": "enemies-encounters-001", "upgrades": "upgrades-003", "bosses": "bosses-002"}, - "standardEnemies": { - "fogAnalyticsCloud": {"hp":30,"radius":18,"speed":84,"contactDps":4,"pulse":{"first":120,"cooldown":180,"telegraph":45,"range":220,"exposure":20}}, - "cableCarCorrelator": {"hp":60,"radius":20,"speed":108,"contactDps":12,"charge":{"first":90,"cooldown":180,"telegraph":30,"ticks":24,"speed":300,"recover":45}}, - "sutroSignalWitch": {"hp":45,"radius":18,"speed":72,"contactDps":6,"range":[220,300],"shot":{"first":60,"cooldown":120,"telegraph":30,"speed":360,"radius":6,"lifetime":90,"damage":10}}, - "autonomousInformant": {"hp":30,"radius":16,"speed":144,"contactDps":8}, - "victorianVendor": {"hp":90,"radius":22,"speed":60,"contactDps":10,"range":[160,220],"mine":{"first":90,"cooldown":180,"telegraph":36,"maximum":2,"arm":30,"lifetime":240,"radius":42,"damage":12}} - }, - "encounters": { - "M-A": {"zone":"Z-03","totals":14,"waves":[ - {"id":"A1","interval":30,"delay":60,"members":{"autonomousInformant":3,"fogAnalyticsCloud":2}}, - {"id":"A2","interval":30,"delay":60,"members":{"cableCarCorrelator":2,"autonomousInformant":2}}, - {"id":"A3","interval":24,"members":{"sutroSignalWitch":1,"fogAnalyticsCloud":2,"autonomousInformant":2}}]}, - "M-B": {"zone":"Z-04","totals":17,"waves":[ - {"id":"B1","interval":24,"delay":60,"members":{"cableCarCorrelator":2,"autonomousInformant":2,"sutroSignalWitch":1}}, - {"id":"B2","interval":24,"delay":75,"members":{"victorianVendor":2,"fogAnalyticsCloud":2,"autonomousInformant":2}}, - {"id":"B3","interval":20,"members":{"sutroSignalWitch":2,"cableCarCorrelator":2,"autonomousInformant":2}}]}, - "M-C": {"zone":"Z-05","totals":25,"activationExposure":1000,"initialDelay":60,"waves":[ - {"id":"C1","interval":20,"delay":45,"members":{"autonomousInformant":3,"cableCarCorrelator":2}}, - {"id":"C2","interval":20,"delay":60,"members":{"fogAnalyticsCloud":2,"sutroSignalWitch":2,"victorianVendor":1}}, - {"id":"C3","interval":18,"delay":75,"members":{"cableCarCorrelator":3,"victorianVendor":2,"autonomousInformant":2}}, - {"id":"C4","interval":18,"members":{"fogAnalyticsCloud":2,"sutroSignalWitch":2,"victorianVendor":2,"autonomousInformant":2}}]} - }, - "elite": {"id":"improperSearchDaemon","hp":450,"radius":26,"speed":108,"contactDps":14,"spawnDelay":90,"cycle":[["pursuit",120],["queryTelegraph",45],["queryResolve",0],["dashTelegraph",36],["dash",30],["recover",60]]}, - "boss": { - "id":"algorithmicModerate","hp":1600,"radius":30,"baseSpeed":96,"baseContactDps":10,"initialDelay":90,"transitionRecovery":45, - "phases":[ - {"id":"publicSafety","minHp":1200,"observation":[105,100],"speed":[100,100],"contact":[100,100],"orbit":[0,100],"sequence":["safetyRationale","narrowTailoring"]}, - {"id":"civilLiberties","minHp":800,"observation":[108,100],"speed":[90,100],"contact":[104,100],"orbit":[72,100],"sequence":["narrowTailoring","safetyRationale","temporaryOrder"]}, - {"id":"temporarySafeguard","minHp":400,"observation":[112,100],"speed":[118,100],"contact":[110,100],"orbit":[18,100],"sequence":["temporaryOrder","narrowTailoring","safetyRationale"]}, - {"id":"independentReview","minHp":1,"observation":[116,100],"speed":[104,100],"contact":[116,100],"orbit":[-55,100],"sequence":["independentReview","narrowTailoring","temporaryOrder"]}], - "attacks": { - "safetyRationale":{"telegraph":45,"range":260,"angle":70000,"damage":18,"cooldown":90}, - "narrowTailoring":{"telegraph":30,"angles":[-12000,0,12000],"speed":420,"radius":7,"lifetime":72,"damage":9,"cooldown":75}, - "temporaryOrder":{"telegraph":48,"active":180,"pulseInterval":30,"exposure":10,"cooldown":120}, - "independentReview":{"telegraph":60,"lanes":6,"projectiles":5,"speed":360,"radius":7,"lifetime":90,"damage":8,"cooldown":105}} - }, - "upgrades": { - "signalJammer":{"index":0,"contactReduction":1,"minimumContact":1,"pulseRatio":[75,100],"heatReinforcementReduction":2}, - "ricochetPulse":{"index":1,"continuations":1,"range":160,"enemyDamage":10,"cameraDamage":1,"continuationRequiresEnemyKill":true}, - "ghostStep":{"index":2,"dodgeSpeed":540,"dodgeTicks":12,"cooldown":90,"postDodgeCameraImmunity":18} - }, - "heat": {"reinforcementArchetype":"autonomousInformant","encounters":["M-A","M-B"],"byDetectionState":{"hidden":0,"observed":0,"tracked":1,"hunted":2,"lockdown":2}}, - "awareness": {"appliesTo":["fogAnalyticsCloud","cableCarCorrelator","sutroSignalWitch","autonomousInformant","victorianVendor"],"sightRangeUnits":320,"allyAlertRadiusUnits":128,"surveillanceAlertState":"tracked","ambushDamageMultiplier":3,"awareEncounters":["M-C"],"heatReinforcementsSpawnAware":true,"unawareDriftPercent":25,"unawareDriftStopUnits":48}, - "patrol": {"integrityPercent":200,"speedPercent":40,"dwellTicks":30,"sightUnits":240,"sightHalfAngleMilliDegrees":45000,"arrivalUnits":4}, - "player": {"integrity":150,"damageTakenPercent":50,"courtThresholdRestorePercent":50,"courtQuietRestorePercent":60} -} diff --git a/Sources/SurveillanceCore/Resources/contracts/combat-content-010.json b/Sources/SurveillanceCore/Resources/contracts/combat-content-010.json new file mode 100644 index 00000000..085681ef --- /dev/null +++ b/Sources/SurveillanceCore/Resources/contracts/combat-content-010.json @@ -0,0 +1,457 @@ +{ + "schemaVersion": "combat-content-010", + "contracts": { + "enemies": "enemies-encounters-001", + "upgrades": "upgrades-003", + "bosses": "bosses-002" + }, + "standardEnemies": { + "fogAnalyticsCloud": { + "hp": 30, + "radius": 18, + "speed": 84, + "contactDps": 4, + "pulse": { + "first": 120, + "cooldown": 180, + "telegraph": 45, + "range": 220, + "exposure": 20 + } + }, + "cableCarCorrelator": { + "hp": 60, + "radius": 20, + "speed": 108, + "contactDps": 12, + "charge": { + "first": 90, + "cooldown": 180, + "telegraph": 30, + "ticks": 24, + "speed": 300, + "recover": 45 + } + }, + "sutroSignalWitch": { + "hp": 45, + "radius": 18, + "speed": 72, + "contactDps": 6, + "range": [ + 220, + 300 + ], + "shot": { + "first": 60, + "cooldown": 120, + "telegraph": 30, + "speed": 360, + "radius": 6, + "lifetime": 90, + "damage": 10 + } + }, + "autonomousInformant": { + "hp": 30, + "radius": 16, + "speed": 144, + "contactDps": 8 + }, + "victorianVendor": { + "hp": 90, + "radius": 22, + "speed": 60, + "contactDps": 10, + "range": [ + 160, + 220 + ], + "mine": { + "first": 90, + "cooldown": 180, + "telegraph": 36, + "maximum": 2, + "arm": 30, + "lifetime": 240, + "radius": 42, + "damage": 12 + } + } + }, + "encounters": { + "M-A": { + "zone": "Z-03", + "totals": 14, + "waves": [ + { + "id": "A1", + "interval": 30, + "delay": 60, + "members": { + "autonomousInformant": 3, + "fogAnalyticsCloud": 2 + } + }, + { + "id": "A2", + "interval": 30, + "delay": 60, + "members": { + "cableCarCorrelator": 2, + "autonomousInformant": 2 + } + }, + { + "id": "A3", + "interval": 24, + "members": { + "sutroSignalWitch": 1, + "fogAnalyticsCloud": 2, + "autonomousInformant": 2 + } + } + ] + }, + "M-B": { + "zone": "Z-04", + "totals": 17, + "waves": [ + { + "id": "B1", + "interval": 24, + "delay": 60, + "members": { + "cableCarCorrelator": 2, + "autonomousInformant": 2, + "sutroSignalWitch": 1 + } + }, + { + "id": "B2", + "interval": 24, + "delay": 75, + "members": { + "victorianVendor": 2, + "fogAnalyticsCloud": 2, + "autonomousInformant": 2 + } + }, + { + "id": "B3", + "interval": 20, + "members": { + "sutroSignalWitch": 2, + "cableCarCorrelator": 2, + "autonomousInformant": 2 + } + } + ] + }, + "M-C": { + "zone": "Z-05", + "totals": 25, + "activationExposure": 1000, + "initialDelay": 60, + "waves": [ + { + "id": "C1", + "interval": 20, + "delay": 45, + "members": { + "autonomousInformant": 3, + "cableCarCorrelator": 2 + } + }, + { + "id": "C2", + "interval": 20, + "delay": 60, + "members": { + "fogAnalyticsCloud": 2, + "sutroSignalWitch": 2, + "victorianVendor": 1 + } + }, + { + "id": "C3", + "interval": 18, + "delay": 75, + "members": { + "cableCarCorrelator": 3, + "victorianVendor": 2, + "autonomousInformant": 2 + } + }, + { + "id": "C4", + "interval": 18, + "members": { + "fogAnalyticsCloud": 2, + "sutroSignalWitch": 2, + "victorianVendor": 2, + "autonomousInformant": 2 + } + } + ] + } + }, + "elite": { + "id": "improperSearchDaemon", + "hp": 450, + "radius": 26, + "speed": 108, + "contactDps": 14, + "spawnDelay": 90, + "cycle": [ + [ + "pursuit", + 120 + ], + [ + "queryTelegraph", + 45 + ], + [ + "queryResolve", + 0 + ], + [ + "dashTelegraph", + 36 + ], + [ + "dash", + 30 + ], + [ + "recover", + 60 + ] + ] + }, + "boss": { + "id": "algorithmicModerate", + "hp": 1600, + "radius": 30, + "baseSpeed": 96, + "baseContactDps": 10, + "initialDelay": 90, + "transitionRecovery": 45, + "phases": [ + { + "id": "publicSafety", + "minHp": 1200, + "observation": [ + 105, + 100 + ], + "speed": [ + 100, + 100 + ], + "contact": [ + 100, + 100 + ], + "orbit": [ + 0, + 100 + ], + "sequence": [ + "safetyRationale", + "narrowTailoring" + ] + }, + { + "id": "civilLiberties", + "minHp": 800, + "observation": [ + 108, + 100 + ], + "speed": [ + 90, + 100 + ], + "contact": [ + 104, + 100 + ], + "orbit": [ + 72, + 100 + ], + "sequence": [ + "narrowTailoring", + "safetyRationale", + "temporaryOrder" + ] + }, + { + "id": "temporarySafeguard", + "minHp": 400, + "observation": [ + 112, + 100 + ], + "speed": [ + 118, + 100 + ], + "contact": [ + 110, + 100 + ], + "orbit": [ + 18, + 100 + ], + "sequence": [ + "temporaryOrder", + "narrowTailoring", + "safetyRationale" + ] + }, + { + "id": "independentReview", + "minHp": 1, + "observation": [ + 116, + 100 + ], + "speed": [ + 104, + 100 + ], + "contact": [ + 116, + 100 + ], + "orbit": [ + -55, + 100 + ], + "sequence": [ + "independentReview", + "narrowTailoring", + "temporaryOrder" + ] + } + ], + "attacks": { + "safetyRationale": { + "telegraph": 45, + "range": 260, + "angle": 70000, + "damage": 18, + "cooldown": 90 + }, + "narrowTailoring": { + "telegraph": 30, + "angles": [ + -12000, + 0, + 12000 + ], + "speed": 420, + "radius": 7, + "lifetime": 72, + "damage": 9, + "cooldown": 75 + }, + "temporaryOrder": { + "telegraph": 48, + "active": 180, + "pulseInterval": 30, + "exposure": 10, + "cooldown": 120 + }, + "independentReview": { + "telegraph": 60, + "lanes": 6, + "projectiles": 5, + "speed": 360, + "radius": 7, + "lifetime": 90, + "damage": 8, + "cooldown": 105 + } + } + }, + "upgrades": { + "signalJammer": { + "index": 0, + "contactReduction": 1, + "minimumContact": 1, + "pulseRatio": [ + 75, + 100 + ], + "heatReinforcementReduction": 2 + }, + "ricochetPulse": { + "index": 1, + "continuations": 1, + "range": 160, + "enemyDamage": 10, + "cameraDamage": 1, + "continuationRequiresEnemyKill": true + }, + "ghostStep": { + "index": 2, + "dodgeSpeed": 540, + "dodgeTicks": 12, + "cooldown": 90, + "postDodgeCameraImmunity": 18 + } + }, + "heat": { + "reinforcementArchetype": "autonomousInformant", + "encounters": [ + "M-A", + "M-B" + ], + "byDetectionState": { + "hidden": 0, + "observed": 0, + "tracked": 1, + "hunted": 2, + "lockdown": 2 + } + }, + "awareness": { + "appliesTo": [ + "fogAnalyticsCloud", + "cableCarCorrelator", + "sutroSignalWitch", + "autonomousInformant", + "victorianVendor" + ], + "sightRangeUnits": 320, + "allyAlertRadiusUnits": 128, + "surveillanceAlertState": "tracked", + "ambushDamageMultiplier": 3, + "awareEncounters": [ + "M-C", + "extraction" + ], + "heatReinforcementsSpawnAware": true, + "unawareDriftPercent": 25, + "unawareDriftStopUnits": 48 + }, + "patrol": { + "integrityPercent": 200, + "speedPercent": 40, + "dwellTicks": 30, + "sightUnits": 240, + "sightHalfAngleMilliDegrees": 45000, + "arrivalUnits": 4 + }, + "player": { + "integrity": 150, + "damageTakenPercent": 50, + "courtThresholdRestorePercent": 50, + "courtQuietRestorePercent": 60 + } +} diff --git a/Sources/SurveillanceCore/Resources/contracts/run-receipt-002.schema.json b/Sources/SurveillanceCore/Resources/contracts/run-receipt-002.schema.json index 7578f081..e2a661f8 100644 --- a/Sources/SurveillanceCore/Resources/contracts/run-receipt-002.schema.json +++ b/Sources/SurveillanceCore/Resources/contracts/run-receipt-002.schema.json @@ -8,7 +8,7 @@ "properties": { "schemaVersion": {"const": "run-receipt-002"}, "identity": {"type": "object", "additionalProperties": false, "required": ["rulesetVersion", "contentVersion", "arenaVersion", "replaySchemaVersion"], "properties": { - "rulesetVersion": {"const": "ss-rules-014"}, "contentVersion": {"const": "civic-seam-content-009"}, "arenaVersion": {"const": "civic-seam-arena-004"}, "replaySchemaVersion": {"const": "runtime-kernel-001"} + "rulesetVersion": {"const": "ss-rules-015"}, "contentVersion": {"const": "civic-seam-content-010"}, "arenaVersion": {"const": "civic-seam-arena-005"}, "replaySchemaVersion": {"const": "runtime-kernel-001"} }}, "seed": {"$ref": "#/$defs/uint64"}, "outcome": {"enum": ["success", "failure", "invalid"]}, diff --git a/Sources/SurveillanceCore/Resources/contracts/runtime-kernel-001.json b/Sources/SurveillanceCore/Resources/contracts/runtime-kernel-001.json index 03e72202..f93f4dcf 100644 --- a/Sources/SurveillanceCore/Resources/contracts/runtime-kernel-001.json +++ b/Sources/SurveillanceCore/Resources/contracts/runtime-kernel-001.json @@ -7,9 +7,9 @@ "required": ["schemaVersion", "rulesetVersion", "contentVersion", "arenaVersion", "seed", "commands"], "properties": { "schemaVersion": {"const": "runtime-kernel-001"}, - "rulesetVersion": {"const": "ss-rules-014"}, - "contentVersion": {"const": "civic-seam-content-009"}, - "arenaVersion": {"const": "civic-seam-arena-004"}, + "rulesetVersion": {"const": "ss-rules-015"}, + "contentVersion": {"const": "civic-seam-content-010"}, + "arenaVersion": {"const": "civic-seam-arena-005"}, "seed": {"type": "integer", "minimum": 0}, "commands": { "type": "array", diff --git a/Sources/SurveillanceCore/Resources/contracts/versions.json b/Sources/SurveillanceCore/Resources/contracts/versions.json index f4ef173c..9a28005f 100644 --- a/Sources/SurveillanceCore/Resources/contracts/versions.json +++ b/Sources/SurveillanceCore/Resources/contracts/versions.json @@ -1,8 +1,8 @@ { "schemaVersion": "runtime-kernel-001", - "rulesetVersion": "ss-rules-014", - "contentVersion": "civic-seam-content-009", - "arenaVersion": "civic-seam-arena-004", + "rulesetVersion": "ss-rules-015", + "contentVersion": "civic-seam-content-010", + "arenaVersion": "civic-seam-arena-005", "componentContracts": { "cameraDestruction": "camera-destruction-001", "combat": "combat-001", @@ -14,8 +14,8 @@ "enemiesEncounters": "enemies-encounters-001", "upgrades": "upgrades-003", "bosses": "bosses-002", - "combatContent": "combat-content-009", - "arenaLayout": "civic-seam-arena-004", + "combatContent": "combat-content-010", + "arenaLayout": "civic-seam-arena-005", "arenaPresentation": "arena-presentation-001", "arenaSchema": "arena-manifest-001", "hudTutorial": "hud-tutorial-001", diff --git a/Sources/SurveillanceCore/Resources/fixtures/complete-run-vectors-001.json b/Sources/SurveillanceCore/Resources/fixtures/complete-run-vectors-001.json index b0549488..f9af5e83 100644 --- a/Sources/SurveillanceCore/Resources/fixtures/complete-run-vectors-001.json +++ b/Sources/SurveillanceCore/Resources/fixtures/complete-run-vectors-001.json @@ -1,6 +1,6 @@ { "fixtureVersion": "complete-run-vectors-001", - "rulesetVersion": "ss-rules-014", + "rulesetVersion": "ss-rules-015", "vectors": [ { "id": "CR-001", diff --git a/Sources/SurveillanceCore/Resources/fixtures/kernel-vectors-001.json b/Sources/SurveillanceCore/Resources/fixtures/kernel-vectors-001.json index 4b54181e..e91a4109 100644 --- a/Sources/SurveillanceCore/Resources/fixtures/kernel-vectors-001.json +++ b/Sources/SurveillanceCore/Resources/fixtures/kernel-vectors-001.json @@ -1,6 +1,6 @@ { "fixtureVersion":"kernel-vectors-001", - "rulesetVersion":"ss-rules-014", + "rulesetVersion":"ss-rules-015", "vectors":[ {"id":"EX-001","initial":{"exposure":0,"state":"hidden","noContactTicks":0},"ticks":100,"contactsPerTick":1,"expected":{"exposure":200,"state":"observed"}}, {"id":"EX-005","initial":{"exposure":300,"state":"observed","noContactTicks":0},"ticks":61,"contactsPerTick":0,"expected":{"exposure":298,"state":"observed","noContactTicks":61}}, diff --git a/Sources/SurveillanceCore/Resources/fixtures/replay-matrix-001.json b/Sources/SurveillanceCore/Resources/fixtures/replay-matrix-001.json index c24f20e5..0bbd0d4a 100644 --- a/Sources/SurveillanceCore/Resources/fixtures/replay-matrix-001.json +++ b/Sources/SurveillanceCore/Resources/fixtures/replay-matrix-001.json @@ -1,6 +1,6 @@ { "fixtureVersion": "replay-matrix-001", - "rulesetVersion": "ss-rules-014", + "rulesetVersion": "ss-rules-015", "entries": [ { "id": "RM-001", diff --git a/Sources/SurveillanceCore/Resources/fixtures/replay-smoke-001.json b/Sources/SurveillanceCore/Resources/fixtures/replay-smoke-001.json index d698a3d1..8cba0f67 100644 --- a/Sources/SurveillanceCore/Resources/fixtures/replay-smoke-001.json +++ b/Sources/SurveillanceCore/Resources/fixtures/replay-smoke-001.json @@ -1,8 +1,8 @@ { "schemaVersion":"runtime-kernel-001", - "rulesetVersion":"ss-rules-014", - "contentVersion":"civic-seam-content-009", - "arenaVersion":"civic-seam-arena-004", + "rulesetVersion":"ss-rules-015", + "contentVersion":"civic-seam-content-010", + "arenaVersion":"civic-seam-arena-005", "seed":1, "commands":[ {"tick":1,"moveX":32767,"moveY":0,"dodgePressed":false}, diff --git a/Sources/SurveillanceCore/World/IsolatedKernel.swift b/Sources/SurveillanceCore/World/IsolatedKernel.swift index 18152038..2b93de26 100644 --- a/Sources/SurveillanceCore/World/IsolatedKernel.swift +++ b/Sources/SurveillanceCore/World/IsolatedKernel.swift @@ -332,8 +332,8 @@ public enum IsolatedKernel { // Temporary Safeguard under the content bands (400–799 of 1600). integrity: 780, radius: 30, - speedUnitsPerSecond: 120, - contactDps: 16, + speedUnitsPerSecond: 96, + contactDps: 10, state: .pursue, stateTicks: 0, spawnTick: 0, @@ -380,8 +380,8 @@ public enum IsolatedKernel { exposurePulse: &pulse, playerDamage: &playerDamage, events: &events, - baseSpeed: 120, - baseContact: 16, + baseSpeed: 96, + baseContact: 10, // No solids here, so the Captain always has a clear line. bounds: AABB(center: VecI(x: 0, y: 0), halfSize: VecI(x: 100_000, y: 100_000)) ) diff --git a/Sources/SurveillanceCore/World/Simulation.swift b/Sources/SurveillanceCore/World/Simulation.swift index a07915f9..02d07d95 100644 --- a/Sources/SurveillanceCore/World/Simulation.swift +++ b/Sources/SurveillanceCore/World/Simulation.swift @@ -913,6 +913,9 @@ public struct Simulation: Equatable, Sendable { private mutating func advanceEncounters(tick: UInt64, forceLockdown: inout Bool) { if tick == 1 { spawnPatrols(tick: tick) } + if state.bossRuntime != nil, !state.bossDefeated { + lockAuthorityCourtRearGates() + } for trigger in state.arena.encounterTriggers { let id = trigger.encounterId ?? trigger.id if id == "improperSearchDaemon" { @@ -1256,9 +1259,29 @@ public struct Simulation: Equatable, Sendable { if let gate = state.gates.firstIndex(where: { $0.id == "gate-mc-forward" }) { state.gates[gate].closed = true } + lockAuthorityCourtRearGates() applyCourtThreshold() } + /// D-127: seal Authority Court rear routes (`gate-mc-forward` and + /// `gate-elite-forward`) once the Player's circle clears `gate-elite-forward` + /// eastward into `Z-06`, preventing kiting the Captain back into `Z-05`. + private mutating func lockAuthorityCourtRearGates() { + let playerCircle = Circle(center: state.player.position, radiusUnits: PlayerBody.radiusUnits) + for gateId in ["gate-mc-forward", "gate-elite-forward"] { + guard let index = state.gates.firstIndex(where: { $0.id == gateId }), + !state.gates[index].closed else { continue } + let box = state.gates[index].box + if gateId == "gate-elite-forward" { + guard state.player.position.x.unitsTruncated > box.maxX + PlayerBody.radiusUnits, + !playerCircle.penetrates(box) else { continue } + } else if playerCircle.penetrates(box) { + continue + } + state.gates[index].closed = true + } + } + /// Captain Court threshold (D-096, bosses.md, BO-020/BO-021): on the /// `bossActivated` tick, ordered after the activation in phase 16, the /// Player is raised to at least `courtThresholdRestorePercent` of @@ -1344,6 +1367,13 @@ public struct Simulation: Equatable, Sendable { type: .extractionCountdownChanged, payload: ["remainingTicks": .integer(Int64(state.extraction.remaining))] ) + if !state.networkBlackout, + state.extraction.pursuitSpawned < 4, + [299, 239, 179, 119].contains(state.extraction.remaining), + spawnExtractionPursuer(tick: tick) + { + state.extraction.pursuitSpawned += 1 + } } if state.extraction.remaining == 0 && state.player.isAlive { succeed(tick: tick) @@ -1362,6 +1392,50 @@ public struct Simulation: Equatable, Sendable { } } + /// D-127: bounded Extraction pursuit from `extractionPressureSockets` + /// (`xp-01..04`) while `networkBlackout == false`. + private mutating func spawnExtractionPursuer(tick: UInt64) -> Bool { + guard let stats = state.content.standardEnemies[.autonomousInformant] else { return false } + let closed = Set(state.gates.filter(\.closed).map(\.id)) + let mounts = state.cameras.map { camera in + AABB( + center: camera.position, + halfSize: VecI(x: camera.mountCollisionRadius, y: camera.mountCollisionRadius) + ) + } + guard let socket = SpawnFairness.select( + sockets: state.arena.extractionPressureSockets, + player: state.player.position, + heading: state.player.facing, + archetypeRadius: stats.radius, + manifest: state.arena, + closedGateIDs: closed, + extraSolids: mounts, + lethalVolumes: lethalVolumes() + ) else { return false } + let id = state.allocator.next() + state.enemies.append( + EnemyBody( + id: id, + archetype: .autonomousInformant, + position: VecI(x: socket.x, y: socket.y).asQ8, + velocity: .zero, + integrity: stats.hp, + radius: stats.radius, + speedUnitsPerSecond: stats.speed, + contactDps: stats.contactDps, + state: .pursue, + stateTicks: 0, + spawnTick: tick, + nextSpecialTick: tick, + lockPosition: nil, + encounterId: "extraction", + awareness: .aware + ) + ) + return true + } + private mutating func emitExposure(_ resolution: ExposureState.Resolution, tick: UInt64) { for change in resolution.changes { events.emit( diff --git a/Sources/SurveillanceCore/World/WorldTypes.swift b/Sources/SurveillanceCore/World/WorldTypes.swift index 7c1b2177..0cab2d54 100644 --- a/Sources/SurveillanceCore/World/WorldTypes.swift +++ b/Sources/SurveillanceCore/World/WorldTypes.swift @@ -51,11 +51,13 @@ public struct ExtractionState: Equatable, Sendable { public var armed: Bool public var remaining: Int public var wasInside: Bool + public var pursuitSpawned: Int - public init(armed: Bool = false, remaining: Int = 300, wasInside: Bool = false) { + public init(armed: Bool = false, remaining: Int = 300, wasInside: Bool = false, pursuitSpawned: Int = 0) { self.armed = armed self.remaining = remaining self.wasInside = wasInside + self.pursuitSpawned = pursuitSpawned } } diff --git a/Tests/SurveillanceCoreTests/ArenaReachabilityTests.swift b/Tests/SurveillanceCoreTests/ArenaReachabilityTests.swift index 2794d3b9..0c89327c 100644 --- a/Tests/SurveillanceCoreTests/ArenaReachabilityTests.swift +++ b/Tests/SurveillanceCoreTests/ArenaReachabilityTests.swift @@ -11,7 +11,7 @@ struct ArenaReachabilityTests { #expect(ArenaReachability.spawnAlleyProtected(arena)) #expect(ArenaReachability.consecutiveZonesConnected(arena)) #expect(ArenaReachability.diagonalSpine(arena)) - // Pinned civic-seam-arena-004.json; do not rewrite coordinates (SS-specs authority). + // Pinned civic-seam-arena-005.json; do not rewrite coordinates (SS-specs authority). #expect( ArenaReachability.authoredSolidOverlaps(arena) == [ "gate gate-mb-forward overlaps mb-05", @@ -54,13 +54,13 @@ struct ArenaReachabilityTests { @Test func arenaLayoutDocumentsBossGateSidestep() throws { let arena = try ArenaManifest.bundled() #expect(ArenaReachability.extractionReachable(arena, bossGateClosed: false)) - // Pinned civic-seam-arena-004.json leaves a 64-unit gap beside gate-boss-extraction + // Pinned civic-seam-arena-005.json leaves a 64-unit gap beside gate-boss-extraction // (2048,384) half (96,16) vs phoenix solids. SS-specs is authority; do not widen the gate. #expect(ArenaReachability.extractionReachable(arena, bossGateClosed: true)) } @Test func arenaAR010ManifestJSONRoundTrip() throws { - let data = SpecBundle.contract("civic-seam-arena-004") + let data = SpecBundle.contract("civic-seam-arena-005") let object = try JSONSerialization.jsonObject(with: data) let first = try #require(CanonicalJSON.parse(object)) let encoded = first.serialize() diff --git a/Tests/SurveillanceCoreTests/AudioDeliveryTests.swift b/Tests/SurveillanceCoreTests/AudioDeliveryTests.swift index 62a3b45e..09490187 100644 --- a/Tests/SurveillanceCoreTests/AudioDeliveryTests.swift +++ b/Tests/SurveillanceCoreTests/AudioDeliveryTests.swift @@ -120,7 +120,7 @@ struct AudioDeliveryTests { @Test func everyBossCueTheProjectorBuildsIsRegistered() throws { let eventIds = Set(try presentation()["audioEventIds"] as! [String]) let content = try JSONSerialization.jsonObject( - with: SpecBundle.contract("combat-content-009") + with: SpecBundle.contract("combat-content-010") ) as! [String: Any] let boss = content["boss"] as! [String: Any] let phases = (boss["phases"] as! [[String: Any]]).map { $0["id"] as! String } diff --git a/Tests/SurveillanceCoreTests/AwarenessTests.swift b/Tests/SurveillanceCoreTests/AwarenessTests.swift index 30d2624b..d3bcad0b 100644 --- a/Tests/SurveillanceCoreTests/AwarenessTests.swift +++ b/Tests/SurveillanceCoreTests/AwarenessTests.swift @@ -379,7 +379,7 @@ struct AwarenessTests { #expect(spec.ambushDamageMultiplier == 3) #expect(spec.unawareDriftPercent == 25) #expect(spec.unawareDriftStopUnits == 48) - #expect(spec.awareEncounters == ["M-C"]) + #expect(spec.awareEncounters == ["M-C", "extraction"]) #expect(spec.heatReinforcementsSpawnAware) #expect(!spec.surveillanceAlerts(.observed)) #expect(spec.surveillanceAlerts(.tracked) && spec.surveillanceAlerts(.hunted) && spec.surveillanceAlerts(.lockdown)) @@ -387,7 +387,7 @@ struct AwarenessTests { @Test func awarenessBlockFailsClosed() throws { let bundled = try #require( - try JSONSerialization.jsonObject(with: BundledResource.data(name: "combat-content-009", subdirectory: "contracts")) + try JSONSerialization.jsonObject(with: BundledResource.data(name: "combat-content-010", subdirectory: "contracts")) as? [String: Any] ) func decodeError(_ key: String?, _ value: Any?) -> CombatContentError? { diff --git a/Tests/SurveillanceCoreTests/CombatContentFailClosedTests.swift b/Tests/SurveillanceCoreTests/CombatContentFailClosedTests.swift index a2efbcea..baad738c 100644 --- a/Tests/SurveillanceCoreTests/CombatContentFailClosedTests.swift +++ b/Tests/SurveillanceCoreTests/CombatContentFailClosedTests.swift @@ -84,7 +84,7 @@ struct CombatContentFailClosedTests { /// or nil if it decoded. private static func mutated(_ mutate: (inout [String: Any]) -> Void) -> CombatContentError? { var root = (try? JSONSerialization.jsonObject( - with: BundledResource.data(name: "combat-content-009", subdirectory: "contracts") + with: BundledResource.data(name: "combat-content-010", subdirectory: "contracts") )) as? [String: Any] ?? [:] mutate(&root) do { diff --git a/Tests/SurveillanceCoreTests/CompleteRunVectorTests.swift b/Tests/SurveillanceCoreTests/CompleteRunVectorTests.swift index 010a4dbd..2e0403c3 100644 --- a/Tests/SurveillanceCoreTests/CompleteRunVectorTests.swift +++ b/Tests/SurveillanceCoreTests/CompleteRunVectorTests.swift @@ -40,6 +40,7 @@ struct CompleteRunVectorTests { #expect(receipt.bossDefeated) #expect(sim.state.terminalDigest != nil) let expected = Self.expectedVectors[upgrade]! + print("STAGE2-CR \(upgrade.rawValue) ticks=\(sim.state.tick) digest=\(sim.state.terminalDigest ?? "")") #expect(sim.state.tick == expected.elapsedTicks) #expect(sim.state.terminalDigest == expected.terminalDigest) #expect(receipt.finalDigest == expected.terminalDigest) diff --git a/Tests/SurveillanceCoreTests/ExtractionCountdownTests.swift b/Tests/SurveillanceCoreTests/ExtractionCountdownTests.swift index dcb88f9c..a62d8b97 100644 --- a/Tests/SurveillanceCoreTests/ExtractionCountdownTests.swift +++ b/Tests/SurveillanceCoreTests/ExtractionCountdownTests.swift @@ -96,4 +96,74 @@ struct ExtractionCountdownTests { } #expect(sim.state.extraction.remaining == countdown) } + + @Test func extractionD127BlackoutSilencesPursuitWhileLiveNetworkSpawnsBoundedInformants() throws { + var contested = try Simulation.make(seed: 1) + contested.testing_completeCombatGraph() + _ = contested.step(command: .neutral(tick: 1)) + contested.testing_setPlayerPosition(extractCenter(contested)) + for tick in 2...200 { + _ = contested.step(command: .neutral(tick: UInt64(tick))) + } + let contestedPursuers = contested.state.enemies.filter { $0.encounterId == "extraction" } + #expect(contested.state.extraction.pursuitSpawned == 4) + #expect(contestedPursuers.count == 4) + #expect(contestedPursuers.allSatisfy { $0.archetype == .autonomousInformant && $0.awareness == .aware }) + + var blackout = try Simulation.make(seed: 1) + for index in blackout.state.cameras.indices { + blackout.testing_destroyCameraAtIndex(index) + } + #expect(blackout.state.networkBlackout) + blackout.testing_completeCombatGraph() + _ = blackout.step(command: .neutral(tick: blackout.state.tick + 1)) + blackout.testing_setPlayerPosition(extractCenter(blackout)) + for _ in 0..<200 { + _ = blackout.step(command: .neutral(tick: blackout.state.tick + 1)) + } + #expect(blackout.state.extraction.pursuitSpawned == 0) + #expect(blackout.state.enemies.filter { $0.encounterId == "extraction" }.isEmpty) + } + + @Test func d127DaemonRoutesAroundSolidAndAuthorityCourtSealsRearGates() throws { + // 1. Daemon Dijkstra pursuit routes around a blocking wall instead of stalling at its face. + var sim = try Simulation.make(seed: 1) + sim.testing_setCollisionSolids([ + AABB(center: VecI(x: 1152, y: 768), halfSize: VecI(x: 64, y: 160)) + ]) + sim.testing_setPlayerPosition(VecI(x: 960, y: 768)) + let daemonId = EntityID(777) + sim.testing_insertEnemy( + EnemyBody( + id: daemonId, + archetype: .improperSearchDaemon, + position: VecI(x: 1344, y: 768).asQ8, + velocity: .zero, + integrity: 450, + radius: 26, + speedUnitsPerSecond: 108, + contactDps: 14, + state: .pursue, + stateTicks: 120, + spawnTick: 0, + nextSpecialTick: 0, + lockPosition: nil, + encounterId: "elite" + ) + ) + _ = sim.step(command: .neutral(tick: 1)) + let daemonAfter = try #require(sim.state.enemies.first { $0.id == daemonId }) + #expect(daemonAfter.position.y.raw != VecI(x: 1344, y: 768).asQ8.y.raw, "Daemon routes vertically around wall corner") + + // 2. Authority Court seals both gate-mc-forward and gate-elite-forward once Player clears into Z-06. + var court = try Simulation.make(seed: 1) + court.testing_completeMobAndEliteGraph() + if let eliteGate = court.state.gates.firstIndex(where: { $0.id == "gate-elite-forward" }) { + court.state.gates[eliteGate].closed = false + } + court.testing_setPlayerPosition(VecI(x: 1984, y: 640)) + _ = court.step(command: .neutral(tick: 1)) + #expect(court.state.gates.first { $0.id == "gate-mc-forward" }?.closed == true) + #expect(court.state.gates.first { $0.id == "gate-elite-forward" }?.closed == true) + } } diff --git a/Tests/SurveillanceCoreTests/HeatReinforcementTests.swift b/Tests/SurveillanceCoreTests/HeatReinforcementTests.swift index 3f6b7243..1f5391a1 100644 --- a/Tests/SurveillanceCoreTests/HeatReinforcementTests.swift +++ b/Tests/SurveillanceCoreTests/HeatReinforcementTests.swift @@ -182,7 +182,7 @@ struct HeatReinforcementTests { @Test func heatBlockFailsClosed() throws { let bundled = try #require( - try JSONSerialization.jsonObject(with: BundledResource.data(name: "combat-content-009", subdirectory: "contracts")) + try JSONSerialization.jsonObject(with: BundledResource.data(name: "combat-content-010", subdirectory: "contracts")) as? [String: Any] ) func decodeError(_ mutate: (inout [String: Any]) -> Void) -> CombatContentError? { diff --git a/Tests/SurveillanceCoreTests/LethalWarningTests.swift b/Tests/SurveillanceCoreTests/LethalWarningTests.swift index bae48480..3fe28e5c 100644 --- a/Tests/SurveillanceCoreTests/LethalWarningTests.swift +++ b/Tests/SurveillanceCoreTests/LethalWarningTests.swift @@ -150,8 +150,15 @@ struct LethalWarningTests { var mined = try Simulation.make(seed: 1) mined.testing_insertMine(at: playerPoint(mined), armRemaining: 0, radius: 42) - mined.testing_setPlayerIntegrity(1) + mined.testing_setPlayerIntegrity(7) + #expect(LethalWarning.isOn(mined.state), "D-127: armed mine (15 -> 7 scaled) warns at <= 7 Integrity") + mined.testing_setPlayerIntegrity(8) #expect(!LethalWarning.isOn(mined.state)) + + var armingMine = try Simulation.make(seed: 1) + armingMine.testing_insertMine(at: playerPoint(armingMine), armRemaining: 15, radius: 42) + armingMine.testing_setPlayerIntegrity(1) + #expect(!LethalWarning.isOn(armingMine.state), "unarmed mine does not warn until 1 tick before arming") } @Test func theWitchTelegraphWarnsAndTheFireTickDoesNot() throws { diff --git a/Tests/SurveillanceCoreTests/MedalTests.swift b/Tests/SurveillanceCoreTests/MedalTests.swift index dcecf6c5..2729c53b 100644 --- a/Tests/SurveillanceCoreTests/MedalTests.swift +++ b/Tests/SurveillanceCoreTests/MedalTests.swift @@ -117,12 +117,12 @@ struct MedalTests { // MARK: - RS-020 SURGICAL - @Test func rs020SurgicalNeedsHalfIntegrity() { + @Test func rs020SurgicalAllowsAtMostSeventyFiveDamageTaken() { var state = Self.success #expect(state.player.maxIntegrity == 150) - state.player.integrity = 74 + state.player.damageTaken = 76 #expect(!Self.medals([], state: state).contains(.surgical)) - state.player.integrity = 75 + state.player.damageTaken = 75 #expect(Self.medals([], state: state).contains(.surgical)) } @@ -135,10 +135,10 @@ struct MedalTests { #expect(Self.medals([], state: state).contains(.blackout)) } - @Test func swiftIsUnderFiveThirty() { + @Test func swiftIsUnderFourFortyFive() { #expect(Self.medals([]).contains(.swift), "the 302-tick run") - #expect(MedalTracker.swift(ticks: 19_799)) - #expect(!MedalTracker.swift(ticks: 19_800)) + #expect(MedalTracker.swift(ticks: 17_099)) + #expect(!MedalTracker.swift(ticks: 17_100)) } // MARK: - RS-021 failure diff --git a/Tests/SurveillanceCoreTests/PacingProbe/DeviceSittingQA.swift b/Tests/SurveillanceCoreTests/PacingProbe/DeviceSittingQA.swift index e8920f08..f47b5ecb 100644 --- a/Tests/SurveillanceCoreTests/PacingProbe/DeviceSittingQA.swift +++ b/Tests/SurveillanceCoreTests/PacingProbe/DeviceSittingQA.swift @@ -70,6 +70,8 @@ import Testing let court = result.milestones["bossActivated"] let clock = Self.clock(result.ticks) print("\(row.name) | \(result.outcome.rawValue) | \(clock) | integrity \(result.playerIntegrity) | medals \(result.medals)") + let damageParts = result.damageBySource.sorted { $0.key < $1.key }.map { "\"\($0.key)\": \($0.value)" }.joined(separator: ", ") + print("STAGE2-QA \(row.name) outcome=\(result.outcome.rawValue) ticks=\(result.ticks) integrity=\(result.playerIntegrity) court=\(court ?? 0) medals=\(result.medals) cameras=\(result.camerasDestroyed) blackout=\(result.networkBlackout) quiet=\(result.quietApproach) failure=\(result.failureReason ?? "nil") damage=[\(damageParts)]") #expect(result.outcome == row.outcome, "\(row.name) outcome") #expect(result.ticks == row.ticks, "\(row.name) ticks") #expect(result.playerIntegrity == row.integrity, "\(row.name) integrity") @@ -82,7 +84,7 @@ import Testing #expect(result.failureReason == row.failure, "\(row.name) failure") #expect(result.damageBySource == row.damage, "\(row.name) damage") #expect(result.medals.contains("SWIFT") == (result.outcome == .success && result.ticks < Medal.swiftTicks)) - #expect(result.medals.contains("SURGICAL") == (result.outcome == .success && result.playerIntegrity * 2 >= 150)) + #expect(result.medals.contains("SURGICAL") == (result.outcome == .success && result.damageTaken <= Medal.surgicalMaxDamageTaken)) #expect(result.medals.contains("BLACKOUT") == (result.outcome == .success && result.networkBlackout)) #expect(result.medals.contains("GHOST") == (result.outcome == .success && result.quietApproach)) } diff --git a/Tests/SurveillanceCoreTests/ReadabilityFinishTests.swift b/Tests/SurveillanceCoreTests/ReadabilityFinishTests.swift index b737d0ba..8c46f766 100644 --- a/Tests/SurveillanceCoreTests/ReadabilityFinishTests.swift +++ b/Tests/SurveillanceCoreTests/ReadabilityFinishTests.swift @@ -12,8 +12,8 @@ struct ReadabilityFinishTests { @Test func arenaFourCarriesTheD094Viewport() throws { let arena = try ArenaManifest.bundled() - #expect(arena.arenaVersion == "civic-seam-arena-004") - #expect(ContractVersions.arena == "civic-seam-arena-004") + #expect(arena.arenaVersion == "civic-seam-arena-005") + #expect(ContractVersions.arena == "civic-seam-arena-005") #expect(arena.viewport.baselineWorldWidth == 704) #expect(arena.viewport.baselineWorldHeight == 326) #expect(arena.viewport.deadZoneWidth == 76) diff --git a/Tests/SurveillanceCoreTests/ReplayMatrixTests.swift b/Tests/SurveillanceCoreTests/ReplayMatrixTests.swift index 58a8e291..21d64f29 100644 --- a/Tests/SurveillanceCoreTests/ReplayMatrixTests.swift +++ b/Tests/SurveillanceCoreTests/ReplayMatrixTests.swift @@ -15,6 +15,7 @@ struct ReplayMatrixTests { let entries = try ReplayMatrix.load() let smoke = try #require(entries.first { $0.fixture == "replay-smoke-001" }) let digest = try ReplayMatrix.tripleRunDigest(smoke) + print("STAGE2-SMOKE digest=\(digest)") #expect(digest == smoke.expectedFinalDigest) } diff --git a/Tests/SurveillanceCoreTests/ReplayTests.swift b/Tests/SurveillanceCoreTests/ReplayTests.swift index 7a759108..0f221077 100644 --- a/Tests/SurveillanceCoreTests/ReplayTests.swift +++ b/Tests/SurveillanceCoreTests/ReplayTests.swift @@ -17,7 +17,7 @@ struct ReplayTests { @Test func duplicateCommandTickIsRejected() throws { let json = """ - {"schemaVersion":"runtime-kernel-001","rulesetVersion":"ss-rules-014","contentVersion":"civic-seam-content-009","arenaVersion":"civic-seam-arena-004","seed":1,"commands":[{"tick":1,"moveX":0,"moveY":0,"dodgePressed":false},{"tick":1,"moveX":0,"moveY":0,"dodgePressed":false}]} + {"schemaVersion":"runtime-kernel-001","rulesetVersion":"ss-rules-015","contentVersion":"civic-seam-content-010","arenaVersion":"civic-seam-arena-005","seed":1,"commands":[{"tick":1,"moveX":0,"moveY":0,"dodgePressed":false},{"tick":1,"moveX":0,"moveY":0,"dodgePressed":false}]} """.data(using: .utf8)! let result = ReplayEnvelope.load(json: json) guard case .failure(.duplicateCommandTick(1)) = result else { @@ -49,7 +49,7 @@ struct ReplayTests { #expect(sim.state.digest() == initial) #expect(sim.state.cameras.allSatisfy { $0.integrity == 3 }) } - @Test(arguments: ["ss-rules-006", "ss-rules-007", "ss-rules-008", "ss-rules-009", "ss-rules-010", "ss-rules-011", "ss-rules-012", "ss-rules-013"]) func previousRulesetFailsClosedBeforeExecution(previous: String) throws { + @Test(arguments: ["ss-rules-006", "ss-rules-007", "ss-rules-008", "ss-rules-009", "ss-rules-010", "ss-rules-011", "ss-rules-012", "ss-rules-013", "ss-rules-014"]) func previousRulesetFailsClosedBeforeExecution(previous: String) throws { let json = String(decoding: SpecBundle.fixture("replay-smoke-001"), as: UTF8.self) .replacingOccurrences(of: ContractVersions.ruleset, with: previous) guard case .failure(.incompatibleIdentity) = ReplayEnvelope.load(json: Data(json.utf8)) else { diff --git a/Tests/SurveillanceCoreTests/TransitPatrolTests.swift b/Tests/SurveillanceCoreTests/TransitPatrolTests.swift index 962b13af..ef8a8bef 100644 --- a/Tests/SurveillanceCoreTests/TransitPatrolTests.swift +++ b/Tests/SurveillanceCoreTests/TransitPatrolTests.swift @@ -463,7 +463,7 @@ struct TransitPatrolTests { /// coordinate, an unknown archetype, the elite, one waypoint, or a /// waypoint in a solid or trigger or outside its zone all fail closed. @Test func patrolsBlockFailsClosed() throws { - let data = BundledResource.data(name: "civic-seam-arena-004", subdirectory: "contracts") + let data = BundledResource.data(name: "civic-seam-arena-005", subdirectory: "contracts") let bundled = try #require(try JSONSerialization.jsonObject(with: data) as? [String: Any]) func load(_ edit: (inout [[String: Any]]) -> Void, drop: Bool = false) -> Error? { var root = bundled diff --git a/Tests/SurveillanceCoreTests/UpgradesContractParityTests.swift b/Tests/SurveillanceCoreTests/UpgradesContractParityTests.swift index 5fc69d46..57dd1e9e 100644 --- a/Tests/SurveillanceCoreTests/UpgradesContractParityTests.swift +++ b/Tests/SurveillanceCoreTests/UpgradesContractParityTests.swift @@ -7,7 +7,7 @@ import Testing /// side alone fails closed instead of shipping a contract with no effect. @Suite struct UpgradesContractParityTests { private static func bundledRoot() throws -> [String: Any] { - let data = BundledResource.data(name: "combat-content-009", subdirectory: "contracts") + let data = BundledResource.data(name: "combat-content-010", subdirectory: "contracts") return try #require(JSONSerialization.jsonObject(with: data) as? [String: Any]) } From 0a3ded44882bc741d3c13807d713bb90e902ccbe Mon Sep 17 00:00:00 2001 From: Daniel Meyer Date: Fri, 27 Nov 2026 20:19:56 -0800 Subject: [PATCH 2/4] fix(stage2): add testing_setGateClosed helper for Authority Court gate seal test --- Sources/SurveillanceCore/World/Simulation.swift | 6 ++++++ Tests/SurveillanceCoreTests/ExtractionCountdownTests.swift | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Sources/SurveillanceCore/World/Simulation.swift b/Sources/SurveillanceCore/World/Simulation.swift index 02d07d95..9d6256b0 100644 --- a/Sources/SurveillanceCore/World/Simulation.swift +++ b/Sources/SurveillanceCore/World/Simulation.swift @@ -1769,6 +1769,12 @@ public struct Simulation: Equatable, Sendable { state.eliteDefeated = true } + mutating func testing_setGateClosed(id: String, closed: Bool) { + if let idx = state.gates.firstIndex(where: { $0.id == id }) { + state.gates[idx].closed = closed + } + } + /// D-109 tests: spawn the Daemon and defeat it through the real defeat /// path, which releases the Lockdown latch for the Court. mutating func testing_defeatElite() { diff --git a/Tests/SurveillanceCoreTests/ExtractionCountdownTests.swift b/Tests/SurveillanceCoreTests/ExtractionCountdownTests.swift index a62d8b97..181eb663 100644 --- a/Tests/SurveillanceCoreTests/ExtractionCountdownTests.swift +++ b/Tests/SurveillanceCoreTests/ExtractionCountdownTests.swift @@ -158,9 +158,10 @@ struct ExtractionCountdownTests { // 2. Authority Court seals both gate-mc-forward and gate-elite-forward once Player clears into Z-06. var court = try Simulation.make(seed: 1) court.testing_completeMobAndEliteGraph() - if let eliteGate = court.state.gates.firstIndex(where: { $0.id == "gate-elite-forward" }) { - court.state.gates[eliteGate].closed = false - } + court.testing_setGateClosed(id: "gate-mc-forward", closed: false) + court.testing_setGateClosed(id: "gate-elite-forward", closed: false) + #expect(court.state.gates.first { $0.id == "gate-mc-forward" }?.closed == false) + #expect(court.state.gates.first { $0.id == "gate-elite-forward" }?.closed == false) court.testing_setPlayerPosition(VecI(x: 1984, y: 640)) _ = court.step(command: .neutral(tick: 1)) #expect(court.state.gates.first { $0.id == "gate-mc-forward" }?.closed == true) From 44898117e7cd796265ac8d6a07e5928c755226d2 Mon Sep 17 00:00:00 2001 From: Daniel Meyer Date: Fri, 27 Nov 2026 20:40:34 -0800 Subject: [PATCH 3/4] chore(stage2): pin ss-rules-015 golden digests, calibrate QA probe rows, and defer AVAudioEngine graph attach --- .github/workflows/ci.yml | 4 +- App/AudioEngine.swift | 41 ++++++++++++++----- SPEC_BASELINE.md | 6 ++- .../SurveillanceCore/ContractVersions.swift | 2 +- .../Presentation/EnvironmentLibrary.swift | 2 +- .../SurveillanceCore/Resources/SPEC_PIN.txt | 2 +- .../contracts/asset-catalog-001.json | 2 +- .../fixtures/complete-run-vectors-001.json | 6 +-- .../Resources/fixtures/replay-matrix-001.json | 2 +- .../CompleteRunVectorTests.swift | 7 ++-- .../EnvironmentLibraryTests.swift | 2 +- .../PacingProbe/DeviceSittingQA.swift | 32 +++++++-------- .../ReplayMatrixTests.swift | 1 - 13 files changed, 64 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed6db6bf..a0e540ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Verify pinned specification - run: grep -q "bcef0c31eafdaa8aa2f2eb2577a57c8664bf7b70" 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 @@ -43,7 +43,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Verify pinned specification - run: grep -q "bcef0c31eafdaa8aa2f2eb2577a57c8664bf7b70" 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 diff --git a/App/AudioEngine.swift b/App/AudioEngine.swift index 44fd2bdb..85dbed1c 100644 --- a/App/AudioEngine.swift +++ b/App/AudioEngine.swift @@ -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() @@ -65,22 +65,25 @@ final class AudioEngine { private(set) var interrupted = false private var suspended = false private var cueTasks: [UUID: Task] = [:] + private static var sessionConfigured = false private var dropTask: Task? - private var interruptionObserver: NSObjectProtocol? + nonisolated(unsafe) private var interruptionObserver: NSObjectProtocol? init() { let catalog = try? AssetCatalog.bundled() deliveredPaths = catalog?.deliveredAudioPaths ?? [:] deliveredGainDb = catalog?.deliveredAudioGainDb ?? [:] - voices = (0.. AVAudioEngine { + if let engine { return engine } + let created = AVAudioEngine() + let pool = (0.. 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 } diff --git a/Sources/SurveillanceCore/Resources/SPEC_PIN.txt b/Sources/SurveillanceCore/Resources/SPEC_PIN.txt index 7271517f..ce8c8206 100644 --- a/Sources/SurveillanceCore/Resources/SPEC_PIN.txt +++ b/Sources/SurveillanceCore/Resources/SPEC_PIN.txt @@ -1,4 +1,4 @@ -SS-specs commit bcef0c31eafdaa8aa2f2eb2577a57c8664bf7b70 +SS-specs commit 91631e59e9afa1d053c5a62775ca4adb35286a22 ruleset ss-rules-015 content civic-seam-content-010 arena civic-seam-arena-005 diff --git a/Sources/SurveillanceCore/Resources/contracts/asset-catalog-001.json b/Sources/SurveillanceCore/Resources/contracts/asset-catalog-001.json index d2a41343..0257b823 100644 --- a/Sources/SurveillanceCore/Resources/contracts/asset-catalog-001.json +++ b/Sources/SurveillanceCore/Resources/contracts/asset-catalog-001.json @@ -2,7 +2,7 @@ "schemaVersion": "asset-catalog-001", "legacyRepository": "scrimshawlife-ctrl/Surveillance-Survivor", "legacyCommit": "3b20d88d6a6e1fe8f07f45f581359d371fa65d98", - "specificationCommit": "bcef0c31eafdaa8aa2f2eb2577a57c8664bf7b70", + "specificationCommit": "91631e59e9afa1d053c5a62775ca4adb35286a22", "entries": [ { "admissionDecision": "excluded", diff --git a/Sources/SurveillanceCore/Resources/fixtures/complete-run-vectors-001.json b/Sources/SurveillanceCore/Resources/fixtures/complete-run-vectors-001.json index f9af5e83..31bc1a21 100644 --- a/Sources/SurveillanceCore/Resources/fixtures/complete-run-vectors-001.json +++ b/Sources/SurveillanceCore/Resources/fixtures/complete-run-vectors-001.json @@ -11,7 +11,7 @@ "camerasDestroyed": 0, "networkBlackout": false, "elapsedTicks": 302, - "terminalDigest": "ecfe771aedf98fb41b3c31030f814018cc8d5d7489d295bc774e31c405f26e79" + "terminalDigest": "88c8d9394fe3e609fc6dd5b38b9bd2f8b5935d1fc8968efc3cec4d75ef32765a" } }, { @@ -23,7 +23,7 @@ "camerasDestroyed": 0, "networkBlackout": false, "elapsedTicks": 302, - "terminalDigest": "a2ab3607007ad0e6fb565b768ff991fcda09e3ba743f2ab705ea7201cde7b773" + "terminalDigest": "c7246e913ed71fb7eb245f34deecd8950696488cbadf1381ab6d019c2d837c52" } }, { @@ -35,7 +35,7 @@ "camerasDestroyed": 0, "networkBlackout": false, "elapsedTicks": 302, - "terminalDigest": "b069083a3adbb5a88ceb2b055d4e053fce4ad91e0ef0653a984f436930fd1c34" + "terminalDigest": "caf5c0e9dc93f8e94d600bc6a2a3b59601f70af91189b815ff8244b536e9435b" } } ] diff --git a/Sources/SurveillanceCore/Resources/fixtures/replay-matrix-001.json b/Sources/SurveillanceCore/Resources/fixtures/replay-matrix-001.json index 0bbd0d4a..f26de200 100644 --- a/Sources/SurveillanceCore/Resources/fixtures/replay-matrix-001.json +++ b/Sources/SurveillanceCore/Resources/fixtures/replay-matrix-001.json @@ -5,7 +5,7 @@ { "id": "RM-001", "fixture": "replay-smoke-001", - "expectedFinalDigest": "2c0e1e780a811e135da3c48fcf3ee693aef90e57e93310158ad9d2f94fc055b0", + "expectedFinalDigest": "a9e64d1831998b572653e692753781468aca68b1e521546f1110eb1fd8f8a7e4", "tripleRunRequired": true } ] diff --git a/Tests/SurveillanceCoreTests/CompleteRunVectorTests.swift b/Tests/SurveillanceCoreTests/CompleteRunVectorTests.swift index 2e0403c3..f065e2aa 100644 --- a/Tests/SurveillanceCoreTests/CompleteRunVectorTests.swift +++ b/Tests/SurveillanceCoreTests/CompleteRunVectorTests.swift @@ -11,15 +11,15 @@ struct CompleteRunVectorTests { private static let expectedVectors: [UpgradeID: ExpectedVector] = [ .signalJammer: ExpectedVector( elapsedTicks: 302, - terminalDigest: "ecfe771aedf98fb41b3c31030f814018cc8d5d7489d295bc774e31c405f26e79" + terminalDigest: "88c8d9394fe3e609fc6dd5b38b9bd2f8b5935d1fc8968efc3cec4d75ef32765a" ), .ricochetPulse: ExpectedVector( elapsedTicks: 302, - terminalDigest: "a2ab3607007ad0e6fb565b768ff991fcda09e3ba743f2ab705ea7201cde7b773" + terminalDigest: "c7246e913ed71fb7eb245f34deecd8950696488cbadf1381ab6d019c2d837c52" ), .ghostStep: ExpectedVector( elapsedTicks: 302, - terminalDigest: "b069083a3adbb5a88ceb2b055d4e053fce4ad91e0ef0653a984f436930fd1c34" + terminalDigest: "caf5c0e9dc93f8e94d600bc6a2a3b59601f70af91189b815ff8244b536e9435b" ) ] @@ -40,7 +40,6 @@ struct CompleteRunVectorTests { #expect(receipt.bossDefeated) #expect(sim.state.terminalDigest != nil) let expected = Self.expectedVectors[upgrade]! - print("STAGE2-CR \(upgrade.rawValue) ticks=\(sim.state.tick) digest=\(sim.state.terminalDigest ?? "")") #expect(sim.state.tick == expected.elapsedTicks) #expect(sim.state.terminalDigest == expected.terminalDigest) #expect(receipt.finalDigest == expected.terminalDigest) diff --git a/Tests/SurveillanceCoreTests/EnvironmentLibraryTests.swift b/Tests/SurveillanceCoreTests/EnvironmentLibraryTests.swift index a7df5197..395cdcb7 100644 --- a/Tests/SurveillanceCoreTests/EnvironmentLibraryTests.swift +++ b/Tests/SurveillanceCoreTests/EnvironmentLibraryTests.swift @@ -123,7 +123,7 @@ struct EnvironmentContractTests { /// never be backed. This is the renderer/contract agreement, asserted at /// the contract so a regression fails here rather than as missing fog. @Test func fogIDsResolveThroughThePresentationContract() throws { - let presentation = try SpecBundle.contract(ContractVersions.presentationAssets) + let presentation = SpecBundle.contract(ContractVersions.presentationAssets) let root = try #require( try JSONSerialization.jsonObject(with: presentation) as? [String: Any] ) diff --git a/Tests/SurveillanceCoreTests/PacingProbe/DeviceSittingQA.swift b/Tests/SurveillanceCoreTests/PacingProbe/DeviceSittingQA.swift index f47b5ecb..dfa959fa 100644 --- a/Tests/SurveillanceCoreTests/PacingProbe/DeviceSittingQA.swift +++ b/Tests/SurveillanceCoreTests/PacingProbe/DeviceSittingQA.swift @@ -29,31 +29,31 @@ import Testing private static let rows: [Row] = [ Row(name: "natural-lower-bound", profile: .firstRun, outcome: .failure, - ticks: 18018, integrity: 0, court: 15849, medals: [], + ticks: 19681, integrity: 0, court: 15289, medals: [], cameras: 8, blackout: true, quiet: false, failure: "playerDeath", - damage: ["algorithmicModerate": 2, "algorithmicModerateProjectile": 37, - "algorithmicModerateSafetyRationale": 36, "autonomousInformant": 3, + damage: ["algorithmicModerateProjectile": 27, + "algorithmicModerateSafetyRationale": 48, "autonomousInformant": 3, "cableCarCorrelator": 2, "improperSearchDaemon": 14, "sutroSignalWitchProjectile": 15, "victorianVendorMine": 66]), Row(name: "natural-style", profile: .competent, outcome: .success, - ticks: 18921, integrity: 7, court: 13229, medals: ["BLACKOUT", "SWIFT"], - cameras: 8, blackout: true, quiet: false, failure: nil, - damage: ["algorithmicModerate": 8, "algorithmicModerateProjectile": 13, + ticks: 18978, integrity: 32, court: 13301, medals: [], + cameras: 7, blackout: false, quiet: false, failure: nil, + damage: ["algorithmicModerateProjectile": 5, "algorithmicModerateSafetyRationale": 63, "autonomousInformant": 2, - "improperSearchDaemon": 30, "sutroSignalWitchProjectile": 15, + "improperSearchDaemon": 21, "sutroSignalWitchProjectile": 15, "victorianVendorMine": 12]), Row(name: "sneaky", profile: .stealth, outcome: .success, - ticks: 15681, integrity: 11, court: 10012, medals: ["GHOST", "SWIFT"], - cameras: 5, blackout: false, quiet: true, failure: nil, - damage: ["algorithmicModerate": 3, "algorithmicModerateProjectile": 22, - "algorithmicModerateSafetyRationale": 54, "autonomousInformant": 3, - "improperSearchDaemon": 45, "sutroSignalWitchProjectile": 20]), + ticks: 15738, integrity: 17, court: 10211, medals: ["GHOST", "SWIFT"], + cameras: 6, blackout: false, quiet: true, failure: nil, + damage: ["algorithmicModerate": 3, "algorithmicModerateProjectile": 14, + "algorithmicModerateSafetyRationale": 72, "autonomousInformant": 3, + "improperSearchDaemon": 21, "sutroSignalWitchProjectile": 20]), Row(name: "loud", profile: .loud, outcome: .success, - ticks: 19479, integrity: 18, court: 13491, medals: ["BLACKOUT", "SWIFT"], + ticks: 19177, integrity: 19, court: 13571, medals: ["BLACKOUT"], cameras: 8, blackout: true, quiet: false, failure: nil, - damage: ["algorithmicModerate": 3, "algorithmicModerateProjectile": 9, + damage: ["algorithmicModerate": 7, "algorithmicModerateProjectile": 4, "algorithmicModerateSafetyRationale": 45, "autonomousInformant": 10, - "improperSearchDaemon": 39, "sutroSignalWitchProjectile": 45, + "improperSearchDaemon": 44, "sutroSignalWitchProjectile": 45, "victorianVendorMine": 6]), ] @@ -70,8 +70,6 @@ import Testing let court = result.milestones["bossActivated"] let clock = Self.clock(result.ticks) print("\(row.name) | \(result.outcome.rawValue) | \(clock) | integrity \(result.playerIntegrity) | medals \(result.medals)") - let damageParts = result.damageBySource.sorted { $0.key < $1.key }.map { "\"\($0.key)\": \($0.value)" }.joined(separator: ", ") - print("STAGE2-QA \(row.name) outcome=\(result.outcome.rawValue) ticks=\(result.ticks) integrity=\(result.playerIntegrity) court=\(court ?? 0) medals=\(result.medals) cameras=\(result.camerasDestroyed) blackout=\(result.networkBlackout) quiet=\(result.quietApproach) failure=\(result.failureReason ?? "nil") damage=[\(damageParts)]") #expect(result.outcome == row.outcome, "\(row.name) outcome") #expect(result.ticks == row.ticks, "\(row.name) ticks") #expect(result.playerIntegrity == row.integrity, "\(row.name) integrity") diff --git a/Tests/SurveillanceCoreTests/ReplayMatrixTests.swift b/Tests/SurveillanceCoreTests/ReplayMatrixTests.swift index 21d64f29..58a8e291 100644 --- a/Tests/SurveillanceCoreTests/ReplayMatrixTests.swift +++ b/Tests/SurveillanceCoreTests/ReplayMatrixTests.swift @@ -15,7 +15,6 @@ struct ReplayMatrixTests { let entries = try ReplayMatrix.load() let smoke = try #require(entries.first { $0.fixture == "replay-smoke-001" }) let digest = try ReplayMatrix.tripleRunDigest(smoke) - print("STAGE2-SMOKE digest=\(digest)") #expect(digest == smoke.expectedFinalDigest) } From 76a79da7021d46a5ca9ac0aab3b0964878518903 Mon Sep 17 00:00:00 2001 From: Daniel Meyer Date: Fri, 27 Nov 2026 21:01:41 -0800 Subject: [PATCH 4/4] fix(stage2): validate historical D-123 receipt against ss-rules-014 while enforcing ss-rules-015 fail-closed --- scripts/test_run_receipt_schema.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/test_run_receipt_schema.py b/scripts/test_run_receipt_schema.py index 3ff7c1b0..091ff315 100644 --- a/scripts/test_run_receipt_schema.py +++ b/scripts/test_run_receipt_schema.py @@ -26,9 +26,9 @@ PHASES = ["publicSafety", "civilLiberties", "temporarySafeguard", "independentReview"] -def validate_receipt(receipt): +def validate_receipt(receipt, validator=VALIDATOR): """Structural schema plus the ordering/projection rules schema cannot express.""" - VALIDATOR.validate(receipt) + validator.validate(receipt) destructions = receipt["cameraDestructions"] for record in destructions: if int(record["cameraId"]) > MAX_UINT64: @@ -187,7 +187,16 @@ def test_recorded_complete_run_preserves_every_gameplay_projection(self): self.assertEqual(hashlib.sha256(raw).hexdigest(), "3718a3233a3429949ecfa20b33b59d2dee03c9e79d80cced3caf1854a57a9316") current = json.loads(raw) - validate_receipt(current) + # Active schema requires ss-rules-015; historical D-123 v2 evidence (ss-rules-014) + # fails closed against the live validator while preserving every D-123 projection. + with self.assertRaises(ValidationError): + VALIDATOR.validate(current) + d123_schema = deepcopy(SCHEMA) + d123_props = d123_schema["properties"]["identity"]["properties"] + d123_props["rulesetVersion"] = {"const": "ss-rules-014"} + d123_props["contentVersion"] = {"const": "civic-seam-content-009"} + d123_props["arenaVersion"] = {"const": "civic-seam-arena-004"} + validate_receipt(current, validator=Draft202012Validator(d123_schema)) historical = json.loads((ROOT / "scripts/fixtures/receipt-v1-observed.json").read_bytes()) historical["schemaVersion"] = "run-receipt-002" historical["upgrade"] = {"id": historical["upgrade"], "contractVersion": "upgrades-003"}