Sync VCC Plus 3.7.1 build 67 source

Refresh reviewed MCP output export, four-drive owned playtests, bounded BASIC readiness, and pinned CMOC 0.1.101 source/patches. Preserve independent source-edition identity, empty libraries, notices and privacy boundaries.

Validated 74 export/privacy checks, pinned dependency sources, and an independent unsigned universal Release build. A subsequent documentation-only correction removes an excluded qualification link; all build inputs remain identical.
This commit is contained in:
Brian Holman committed 2026-11-17 08:42:27 -07:00
1 parent 4abc194001
commit 5534005799
54 files changed
+2950 -435

No files matched your search

@@ -27,6 +27,32 @@ final class SoftwareLibraryPublishedGameTests: XCTestCase {
diskSHA256: "d05ab25fd90171b048cce54f3af18ca6d0bd81335e138044ff05315e99cbf582", ramKiB: 128, keyboardOnly: false)
]
}
/// These are candidate source-rebuild identities, not publication receipts.
/// Independently replayed in owned folders with the pinned unsigned development
/// runtime; this is not execution of the Developer ID-signed packaged compiler.
private struct CandidateSourceBaseline: Sendable {
let sourceZIP: String
let makefile: String
let binary: String
let disk: String
static let runtimeManifest = "a4dd934aed84a0b139e1d88b8a607d52ff7f6fc66c3bd3be30db7fd5d40dcbef"
static let compiler = "5769c5ffe14f0adad61c41aa72337261acc6fd882e7e6656bdcf350b414930a1"
static let wrapper = "b83e6ea79da5160cd85f5b7665524f19f717a4a6e76e12e661900dc071a1cea6"
static let reviewed: [String: Self] = [
"bone-quest": .init(sourceZIP: "99f9770965f9d2061f764ebe704da95f7f037a42c5df21a959b558b25d704da6",
makefile: "b0e9816d4b1712cd903b1e51ebb5c80901fb45ba4233f6b091e6e97fe5cdd1d7",
binary: "f57e5818d070009cb2713fe4d70f8f0cba2bd2e5c54833d4911348a708bdb0f0",
disk: "8614c31b92a5f3b70b7b35792414b7fd43042614de2bda4b6ff508711f157a8d"),
"capital-quest": .init(sourceZIP: "5f0cbc6ad58594a1c21a77079b2db4a2862546b6f701c2d515fe04f9727568f3",
makefile: "880c46b17747ed0cbe33c386b21f319b9e453ab64cab185bd7f802293226a886",
binary: "9b2fe10ebca6c515d3cb45f649ea772058be4186b8abac3fec95c3b69d955e6b",
disk: "28a07495e1afa5702fd7c9def0aa2c94d8671ec6cfd6de2c57d5b92b4aa0c930"),
"quadrapassel": .init(sourceZIP: "710c8e1e9d6cfbd800d5719e30ad2057aa9bade8c81f8d1e5374634b4d208438",
makefile: "70144a013bdf2ad4c7ea996b53a1d304d7f440236d91f22fc7e63481fb258a92",
binary: "4893e44f7ba33c3fa3b8f8268588104038dd402fae7cd3dcdbeeca11aa3e6df5",
disk: "49e931b0530214d9cdb2afd4f5a1f3819695b3267e70fec04dcc69f86fc5ce9f")
]
}
private struct Game: Sendable {
let fixture: Fixture
let publicationID: String
@@ -148,7 +174,7 @@ final class SoftwareLibraryPublishedGameTests: XCTestCase {
}
throw ProfileFailure.message("Published-game fixture did not settle")
}
@MainActor private func withMachine(output: URL, use6309: Bool,
@MainActor private func withMachine(output: URL, use6309: Bool, startingMachine: MachineSettings? = nil,
body: (MachineModel, VCCMachineController, UserDefaults) async throws -> Void) async throws {
_ = NSApplication.shared // Standalone hostless runs still need AppKit's input lifecycle.
let suite = "PublishedGame-" + UUID().uuidString
@@ -166,6 +192,7 @@ final class SoftwareLibraryPublishedGameTests: XCTestCase {
&& FileManager.default.fileExists(atPath: profile.media.rom!.path), "Stage explicit local CoCo/Disk BASIC ROM inputs")
profile.sound = false; profile.videoOutput = 0
profile.machine.ram = 2; profile.machine.use6309 = !use6309
if let startingMachine { profile.machine = startingMachine }
profile.input.right.source = .keyboard; profile.input.left.source = .none
var cartridges = CartridgeAssignments(); cartridges.multiPak = true; cartridges.mpiConfigured = true
cartridges.physicalSlot = 4; cartridges.slots[4].kind = .floppy; profile.media.cartridges = cartridges
@@ -209,6 +236,32 @@ final class SoftwareLibraryPublishedGameTests: XCTestCase {
guard made else { throw ProfileFailure.message("Published acceptance image could not be rendered") }
rgba = pixels
}
func changedPixelFraction(comparedTo before: Raster) -> Double {
guard width == before.width, height == before.height else { return 1 }
var changed = 0
for offset in stride(from: 0, to: rgba.count, by: 4) {
if (0..<3).contains(where: { abs(Int(rgba[offset + $0]) - Int(before.rgba[offset + $0])) > 28 }) { changed += 1 }
}
return Double(changed) / Double(width * height)
}
/// Compare only authored, static PLAY UI in the 320x192 reference.
/// Coordinates map through the captured active picture, never full-frame
/// borders. Black background, pieces, preview tiles and numbers are omitted.
func staticForegroundMatch(to reference: Raster, regions: [CGRect]) -> (score: Double, pixels: Int, matched: Int) {
var foreground = 0, matched = 0
for region in regions {
guard region.minX >= 0, region.minY >= 0,
region.maxX <= CGFloat(reference.width), region.maxY <= CGFloat(reference.height) else { return (0, 0, 0) }
for y in Int(region.minY)..<Int(region.maxY) { for x in Int(region.minX)..<Int(region.maxX) {
let r = (y * reference.width + x) * 4
if (0..<3).allSatisfy({ reference.rgba[r + $0] <= 28 }) { continue }
foreground += 1
let a = ((y * height / reference.height) * width + x * width / reference.width) * 4
if (0..<3).allSatisfy({ abs(Int(rgba[a + $0]) - Int(reference.rgba[r + $0])) <= 28 }) { matched += 1 }
} }
}
return (foreground > 100 ? Double(matched) / Double(foreground) : 0, foreground, matched)
}
func similarity(to reference: Raster) -> Double {
var histogram: [UInt32: Int] = [:]
for index in stride(from: 0, to: reference.rgba.count, by: 4) {
@@ -325,6 +378,257 @@ final class SoftwareLibraryPublishedGameTests: XCTestCase {
XCTAssertEqual(afterBuild.logicalMemory, before.logicalMemory)
return report
}
@MainActor private func startCandidateDOS(_ model: MachineModel, controller: VCCMachineController) async throws {
// Native owned-media qualification observes the core's readiness only.
// The shared-program MCP screen surface intentionally rejects writable
// disks; it is not the permission path for this disposable native session.
// Visible OK precedes BASIC's direct-input loop, so require both actual
// direct input and a stable final OK on mature guest fields before typing.
let initial = await step(controller.snapshot)
guard initial.errorMessage == nil else {
throw ProfileFailure.message(initial.errorMessage ?? "Candidate Disk BASIC startup failed")
}
var ready = false, readyObservations = 0
var firstReadyField: UInt64?
var lastText = "(unavailable)"
var last = initial
let deadline = ContinuousClock.now.advanced(by: .seconds(15))
while ContinuousClock.now < deadline {
let readiness = await step(controller.assistantReadiness)
let (text, snapshot): (String?, VCCMachineSnapshot) = await withCheckedContinuation { done in
controller.inspectScreenText { done.resume(returning: ($0, $1)) }
}
last = snapshot; lastText = text ?? "(unavailable)"
guard readiness.errorMessage == nil, snapshot.errorMessage == nil,
readiness.state == .running, snapshot.state == .running,
readiness.generation == initial.generation, snapshot.generation == initial.generation else {
throw ProfileFailure.message(snapshot.errorMessage ?? readiness.errorMessage ?? "Candidate Disk BASIC changed during startup readiness checks")
}
let lines = (text ?? "").split(separator: "\n").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
guard !lines.contains(where: { $0.hasPrefix("?") }) else {
throw ProfileFailure.message("Candidate Disk BASIC reported an error before DOS; no command was sent")
}
if readiness.assistantDirectPrompt?.boolValue == true,
readiness.assistantEmptyBASIC?.boolValue == true,
lines.last == "OK", readiness.pasteRemaining == 0, snapshot.pasteRemaining == 0 {
readyObservations += 1
if firstReadyField == nil { firstReadyField = readiness.frames }
if readyObservations >= 2, let firstReadyField, readiness.frames >= firstReadyField + 6 {
ready = true; break
}
} else { readyObservations = 0; firstReadyField = nil }
try await Task.sleep(for: .milliseconds(100))
}
guard ready else {
throw ProfileFailure.message("Candidate disk did not reach stable native direct Disk BASIC readiness; no command was sent. Screen: " + lastText +
String(format: " PC %04X, frame %llu.", last.programCounter, last.frames))
}
try await settle(model)
guard model.canPaste else { throw ProfileFailure.message("Candidate Disk BASIC was not ready for ordinary keyboard input") }
model.startPaste(try CocoPaste("DOS\n", mode: .text))
try await settle(model)
}
/// The published-binary test below deliberately retains its original hash
/// contract. This separate opt-in checks the reviewed compiler's different
/// outputs and actually boots those outputs, never a substituted old disk.
@MainActor func testReviewedCMOC101SourceRebuildsBootAndRespondOnBothGuestCPUs() async throws {
guard let path = ProcessInfo.processInfo.environment["VCC_TEST_TOOLCHAIN_DIR"] else {
throw XCTSkip("Set the pinned unsigned development toolchain and private published-game fixture inputs for current-compiler qualification")
}
guard path.hasPrefix("/") else { throw ProfileFailure.message("Candidate compiler qualification requires an absolute runtime path") }
let toolchain = URL(fileURLWithPath: path)
let manifestData = try Data(contentsOf: toolchain.appendingPathComponent("manifest.json"))
let compilerData = try Data(contentsOf: toolchain.appendingPathComponent("libexec/cmoc"))
let wrapperData = try Data(contentsOf: toolchain.appendingPathComponent("bin/cmoc"))
guard Self.sha(manifestData) == CandidateSourceBaseline.runtimeManifest,
Self.sha(compilerData) == CandidateSourceBaseline.compiler,
Self.sha(wrapperData) == CandidateSourceBaseline.wrapper else {
throw ProfileFailure.message("Unknown candidate compiler/runtime identity: independently review and qualify new rebuild baselines before accepting these bytes")
}
let inputs = try await inputs()
var results: [[String: Any]] = []
for game in inputs.games {
guard let expected = CandidateSourceBaseline.reviewed[game.slug],
game.owned.source.package.sha256 == expected.sourceZIP else {
throw ProfileFailure.message("The published source package has no reviewed candidate rebuild baseline")
}
let gameOutput = inputs.output.appendingPathComponent(game.slug)
try FileManager.default.createDirectory(at: gameOutput, withIntermediateDirectories: true)
let importer = SoftwareLibrarySourceImporter(cacheDirectory: gameOutput.appendingPathComponent("Candidate source originals"))
let imported = try await importer.importProject(game.owned.source, to: gameOutput.appendingPathComponent("Candidate Source With Spaces"))
guard Self.sha(try Data(contentsOf: imported.originalPackage)) == expected.sourceZIP else {
throw ProfileFailure.message("Candidate source archive differs from the reviewed immutable package")
}
let project = try CMOCProject.open(at: imported.projectDirectory)
let originalInputs = try project.inputFiles()
let originalMakefile = try Data(contentsOf: project.makefileURL)
guard Self.sha(originalMakefile) == expected.makefile else {
throw ProfileFailure.message("Candidate source Makefile differs from the reviewed unmodified recipe")
}
let build = try await CMOCBuildService(toolchain: toolchain, buildRoot: gameOutput.appendingPathComponent("Candidate source qualification"))
.build(project: project, overlays: [:], action: .disk, configuration: "Release")
let disk = try Data(contentsOf: XCTUnwrap(build.diskURL))
guard Self.sha(build.binaryData) == expected.binary, build.diskSHA256 == expected.disk,
Self.sha(disk) == expected.disk else {
throw ProfileFailure.message("Candidate compiler output differs from the independently replayed exact BIN/DSK baseline")
}
XCTAssertEqual(build.configurationName, "Release")
XCTAssertEqual(try project.inputFiles(), originalInputs, "Candidate compilation must preserve every imported input")
XCTAssertEqual(try Data(contentsOf: project.makefileURL), originalMakefile)
let hero = try artwork(game.record["artwork"]["hero"], id: game.slug + "-candidate-title")
let referenceData = try await SoftwareLibraryArtworkCache().thumbnail(for: hero, directory: gameOutput.appendingPathComponent("Artwork"))
let reference = try Raster(referenceData)
let gameplayReferenceSHA = "dd6c5b0e02e3a7c995056a436a4379ab617c7a0c60ddf246ad5ac9163e5239b8"
// Source-authored stable captions and all four well borders only.
// Exclude board cells, NEXT/HOLD previews and changing score values.
let gameplayStaticRegions: [CGRect] = [
CGRect(x: 32, y: 0, width: 168, height: 8),
CGRect(x: 32, y: 32, width: 40, height: 8),
CGRect(x: 32, y: 64, width: 40, height: 8),
CGRect(x: 32, y: 96, width: 40, height: 8),
CGRect(x: 216, y: 24, width: 32, height: 8),
CGRect(x: 216, y: 80, width: 32, height: 8),
CGRect(x: 32, y: 144, width: 48, height: 8),
CGRect(x: 32, y: 168, width: 72, height: 8),
CGRect(x: 118, y: 22, width: 84, height: 2),
CGRect(x: 118, y: 184, width: 84, height: 2),
CGRect(x: 118, y: 24, width: 2, height: 160),
CGRect(x: 200, y: 24, width: 2, height: 160)
]
let gameplayReference: Raster?
if game.slug == "quadrapassel" {
let gameplayData = try Data(contentsOf: imported.projectDirectory.appendingPathComponent("docs/manual/images/gameplay.png"))
guard Self.sha(gameplayData) == gameplayReferenceSHA else {
throw ProfileFailure.message("The source-authored Quadrapassel PLAY reference changed; review it before accepting gameplay qualification")
}
let raster = try Raster(gameplayData)
guard raster.width == 320, raster.height == 192 else {
throw ProfileFailure.message("The reviewed Quadrapassel PLAY reference must use its authored 320x192 coordinates")
}
gameplayReference = raster
} else { gameplayReference = nil }
for use6309 in [false, true] {
let output = gameOutput.appendingPathComponent(use6309 ? "candidate-6309" : "candidate-6809")
try FileManager.default.createDirectory(at: output, withIntermediateDirectories: true)
let working = output.appendingPathComponent("CandidateWorking.DSK")
try disk.write(to: working, options: .withoutOverwriting)
var settings = MachineSettings()
settings.use6309 = use6309; settings.ram = game.fixture.ramKiB == 128 ? 0 : 1
try await withMachine(output: output, use6309: use6309, startingMachine: settings) { model, controller, _ in
try await model.insertDiskFromMedia(working, drive: 0, execution: .run, reset: .coldRestart)
try await startCandidateDOS(model, controller: controller)
let (first, titleSimilarity) = try await waitForTitle(reference: reference, controller: controller,
output: output.appendingPathComponent("candidate-first-title.png"))
XCTAssertEqual(first.use6309, use6309)
XCTAssertEqual(first.ramConfiguration, UInt(settings.ram))
XCTAssertEqual(first.videoOutput, 0); XCTAssertTrue(first.disks[0].mounted)
XCTAssertFalse(first.debuggerDevelopmentAttached)
XCTAssertNil(first.errorMessage)
XCTAssertEqual(first.cpuOverclock, 1); XCTAssertEqual(first.frameInterval, 1); XCTAssertFalse(first.fastForward)
// An idle title must remain recognizable before ordinary input.
// A cursor blink or an animated tile alone cannot qualify a start.
try await Task.sleep(nanoseconds: 500_000_000)
let idle = await step(controller.snapshot)
let titleArea = reference.width == 640 && reference.height == 480 ? VideoGeometry.fullFrame : idle.activeVideoRect
let idleRaster = try Raster(ScreenCapture(pixels: idle.pixels, area: titleArea).png())
let idleTitleSimilarity = idleRaster.similarity(to: reference)
guard idle.state == .running, idle.generation == first.generation, idle.errorMessage == nil,
idleTitleSimilarity >= 0.95 else {
throw ProfileFailure.message("Candidate title changed before start input; inspect the idle scene before accepting a transition")
}
let beforePixels = try ScreenCapture(pixels: first.pixels, area: VideoGeometry.fullFrame).png()
let before = try Raster(beforePixels)
let key = game.slug == "quadrapassel" ? " " : "1"
var keyboard = CocoKeyboard()
keyboard.press(code: game.slug == "quadrapassel" ? 49 : 18, characters: key)
let mask = keyboard.mask
XCTAssertNotEqual(mask, 0)
controller.setKeyboardMask(mask)
try await Task.sleep(nanoseconds: 200_000_000)
controller.setKeyboardMask(0)
var progress: (VCCMachineSnapshot, Data, Double, Double)?
var gameplayProof: (score: Double, pixels: Int, matched: Int)?
var changedFrames = 0
for _ in 0..<80 {
try await Task.sleep(nanoseconds: 100_000_000)
let snapshot = await step(controller.snapshot)
guard snapshot.state == .running, snapshot.generation == first.generation,
snapshot.frames > idle.frames + 4, snapshot.pasteRemaining == 0, snapshot.errorMessage == nil else { continue }
let png = try ScreenCapture(pixels: snapshot.pixels, area: VideoGeometry.fullFrame).png()
let difference = try Raster(png).changedPixelFraction(comparedTo: before)
let sceneArea = reference.width == 640 && reference.height == 480 ? VideoGeometry.fullFrame : snapshot.activeVideoRect
let scene = try Raster(ScreenCapture(pixels: snapshot.pixels, area: sceneArea).png())
let titleSimilarity = scene.similarity(to: reference)
let staticMatch: (score: Double, pixels: Int, matched: Int)?
if let gameplayReference {
let activeScene = try Raster(ScreenCapture(pixels: snapshot.pixels, area: snapshot.activeVideoRect).png())
staticMatch = activeScene.staticForegroundMatch(to: gameplayReference, regions: gameplayStaticRegions)
} else { staticMatch = nil }
let gameplayReady = staticMatch.map { $0.score >= 0.95 && $0.pixels > 100 } ?? true
changedFrames = difference >= 0.005 && titleSimilarity < 0.90 && gameplayReady ? changedFrames + 1 : 0
if changedFrames >= 2 {
progress = (snapshot, png, difference, titleSimilarity); gameplayProof = staticMatch; break
}
}
guard let progress else { throw ProfileFailure.message("Candidate-built game did not leave its stable title scene after normal start input") }
let (guestText, inspected): (String?, VCCMachineSnapshot) = await withCheckedContinuation { done in
controller.inspectScreenText { done.resume(returning: ($0, $1)) }
}
XCTAssertNil(inspected.errorMessage)
XCTAssertEqual(inspected.generation, first.generation)
if let guestText {
let lines = guestText.uppercased().split(whereSeparator: \.isNewline).map { $0.trimmingCharacters(in: .whitespaces) }
guard !lines.contains(where: { $0 == "OK" || $0.hasPrefix("?") }) else {
throw ProfileFailure.message("Candidate start input returned to BASIC or an error prompt instead of remaining in the game")
}
}
XCTAssertEqual(progress.0.cpuOverclock, 1); XCTAssertEqual(progress.0.frameInterval, 1); XCTAssertFalse(progress.0.fastForward)
try progress.1.write(to: output.appendingPathComponent("candidate-after-start-key.png"), options: .atomic)
_ = await step(controller.pause); try await settle(model)
let retainedBeforeRestart = try await model.snapshotDiskCopy(inDrive: 0)
model.reset(); try await settle(model); model.resume(); try await settle(model)
let retainedAfterRestart = try await model.snapshotDiskCopy(inDrive: 0)
XCTAssertEqual(retainedAfterRestart, retainedBeforeRestart, "Cold restart must keep the owned working disk rather than replace it from a published package")
try await startCandidateDOS(model, controller: controller)
let (second, restartSimilarity) = try await waitForTitle(reference: reference, controller: controller,
output: output.appendingPathComponent("candidate-restarted-title.png"))
XCTAssertNotEqual(second.generation, first.generation)
XCTAssertEqual(second.use6309, use6309); XCTAssertEqual(second.ramConfiguration, UInt(settings.ram))
XCTAssertNil(second.errorMessage)
XCTAssertEqual(second.cpuOverclock, 1); XCTAssertEqual(second.frameInterval, 1); XCTAssertFalse(second.fastForward)
XCTAssertEqual(Self.sha(try Data(contentsOf: XCTUnwrap(build.diskURL))), expected.disk, "The frozen candidate artifact must not be the guest's writable copy")
var gameplayReceipt: [String: Any] = [:]
if let gameplayProof {
gameplayReceipt = ["gameplay_reference_sha256": gameplayReferenceSHA,
"gameplay_reference_size": [320, 192],
"gameplay_static_regions": gameplayStaticRegions.map { [Int($0.minX), Int($0.minY), Int($0.width), Int($0.height)] },
"gameplay_static_foreground_pixels": gameplayProof.pixels,
"gameplay_static_matched_pixels": gameplayProof.matched,
"gameplay_static_foreground_similarity": gameplayProof.score,
"gameplay_static_matching_observations": changedFrames]
}
results.append(["game": game.slug, "cpu": use6309 ? "6309" : "6809", "host_architecture": Self.architecture,
"source_zip_sha256": expected.sourceZIP, "makefile_sha256": expected.makefile,
"compiler_sha256": CandidateSourceBaseline.compiler, "runtime_manifest_sha256": CandidateSourceBaseline.runtimeManifest,
"runtime_kind": "pinned_unsigned_development_runtime", "packaged_compiler_execution": false,
"configuration": "Release", "candidate_binary_sha256": expected.binary, "candidate_disk_sha256": expected.disk,
"published_disk_sha256": game.fixture.diskSHA256, "candidate_is_published": false,
"ram_kib": game.fixture.ramKiB, "first_title_foreground_similarity": titleSimilarity,
"restart_title_foreground_similarity": restartSimilarity, "normal_start_key": key == " " ? "space" : key,
"idle_title_foreground_similarity": idleTitleSimilarity, "post_start_title_foreground_similarity": progress.3,
"stock_speed": true, "basic_or_error_prompt_after_start": false,
"visible_changed_pixel_fraction": progress.2, "normal_input_fields_advanced": progress.0.frames - first.frames,
"working_disk_preserved_across_restart": true,
"coverage": "Exact unsigned-development-runtime rebuild, normal DOS startup, rendered title, ordinary start-key title-to-game transition and cold restart; not packaged compiler execution or a full game playthrough"].merging(gameplayReceipt) { _, proof in proof })
try JSONSerialization.data(withJSONObject: results, options: [.prettyPrinted, .sortedKeys])
.write(to: inputs.output.appendingPathComponent("CandidateSourceAcceptance.json"), options: .atomic)
}
}
}
XCTAssertEqual(results.count, Fixture.approved.count * 2)
}
@MainActor func testPublishedFirstAndCachedPlaySourceAndManualAcceptance() async throws {
let inputs = try await inputs()
var results: [[String: Any]] = []