Sync source edition with VCC Plus 3.7.0 build 63

This commit is contained in:
Brian Holman committed 2026-11-14 01:43:46 -07:00
1 parent c652a5276d
commit b2ecec4d87
86 files changed
+10519 -472

No files matched your search

+34 -12
View File
@@ -607,7 +607,7 @@ final class MCPCMOC: ObservableObject {
try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: false, attributes: [.posixPermissions: 0o700])
do {
let server = try MCPTransport(handler: handler)
let bytes = try JSONSerialization.data(withJSONObject: ["token": secret, "kind": "cmoc", "toolset": 11, "playtestMedia": approvedPlaytests, "playtestCallContext": approvedPlaytests, "projectRefresh": true, "projectDiagnostics": true, "playtestAudio": approvedPlaytests, "playtestProcessors": approvedPlaytests, "playtestJoysticks": approvedPlaytests, "customMake": scope.customMake, "playtest": approvedPlaytests, "canPropose": true,
let bytes = try JSONSerialization.data(withJSONObject: ["token": secret, "kind": "cmoc", "toolset": 12, "playtestVideo": approvedPlaytests, "playtestMedia": approvedPlaytests, "playtestCallContext": approvedPlaytests, "projectRefresh": true, "projectDiagnostics": true, "playtestAudio": approvedPlaytests, "playtestProcessors": approvedPlaytests, "playtestJoysticks": approvedPlaytests, "customMake": scope.customMake, "playtest": approvedPlaytests, "canPropose": true,
"socket": server.unixPath, "port": Int(server.port), "version": 1])
return (server, try MCPGrantFile(create: destination, data: bytes))
} catch { try? FileManager.default.removeItem(at: dir); throw error }
@@ -698,13 +698,15 @@ final class MCPCMOC: ObservableObject {
if let latestRefreshID, let record = refreshRecords[latestRefreshID] { fields["refresh"] = projectRefreshFields(record) }
result = fields
case "get_capabilities" where args.isEmpty:
result = ["tools": Self.tools + (callContextApproved ? ["get_call_context"] : []) + (playtestMediaApproved ? ["list_playtest_media", "exchange_playtest_media"] : []) + (playtestsApproved ? ["list_playtest_disks", "start_playtest", "playtest_input", "get_playtest_input", "playtest_debug", "capture_playtest", "capture_playtest_graphics", "capture_playtest_audio", "restart_playtest", "stop_playtest"] : []), "playtest_media_exchange": playtestMediaApproved, "playtest_media_drive": "FD0", "playtest_media_maximum_disks": 9, "playtest_media_maximum_disk_bytes": 512 * 1024, "call_context": callContextApproved, "call_context_maximum_stack_bytes": 64, "input_diagnostics": true, "playtest_joystick_input": playtestsApproved, "playtest_joystick_interfaces": playtestsApproved ? ["standard"] : [], "playtest_joystick_axis_min": 0, "playtest_joystick_axis_max": 16383, "playtest_joystick_axis_center": 8191, "owned_playtests": playtestsApproved, "async_playtest_start": playtestsApproved, "retained_playtest_disks": playtestsApproved, "period_key": playtestsApproved, "graphics_buffer_capture": playtestsApproved, "custom_gime_canvases": playtestsApproved, "source_only_debugging": playtestsApproved, "verified_flat_debugging": playtestsApproved, "audio_capture": playtestsApproved, "audio_capture_maximum_fields": 120, "audio_capture_maximum_clips": 16, "audio_capture_maximum_bytes": 4 * 1024 * 1024, "build_diagnostics": true, "project_refresh": true, "input_status": refreshProblem ?? "approved", "changed_input_paths": Array(observedInputChanges.prefix(128)).map(\.path), "changed_input_paths_total": observedInputChanges.count, "changed_input_paths_truncated": observedInputChanges.count > 128, "kind": "cmoc", "app": "VCC Plus OSS",
result = ["tools": Self.tools + (callContextApproved ? ["get_call_context"] : []) + (playtestMediaApproved ? ["list_playtest_media", "exchange_playtest_media"] : []) + (playtestsApproved ? ["list_playtest_disks", "start_playtest", "playtest_input", "get_playtest_input", "playtest_debug", "capture_playtest", "capture_playtest_graphics", "capture_playtest_audio", "start_playtest_video", "stop_playtest_video", "read_playtest_video", "restart_playtest", "stop_playtest"] : []), "playtest_media_exchange": playtestMediaApproved, "playtest_media_drive": "FD0", "playtest_media_maximum_disks": 9, "playtest_media_maximum_disk_bytes": 512 * 1024, "call_context": callContextApproved, "call_context_maximum_stack_bytes": 64, "input_diagnostics": true, "playtest_joystick_input": playtestsApproved, "playtest_joystick_interfaces": playtestsApproved ? ["standard"] : [], "playtest_joystick_axis_min": 0, "playtest_joystick_axis_max": 16383, "playtest_joystick_axis_center": 8191, "owned_playtests": playtestsApproved, "async_playtest_start": playtestsApproved, "retained_playtest_disks": playtestsApproved, "period_key": playtestsApproved, "graphics_buffer_capture": playtestsApproved, "custom_gime_canvases": playtestsApproved, "source_only_debugging": playtestsApproved, "verified_flat_debugging": playtestsApproved, "video_capture": playtestsApproved, "video_capture_maximum_fields": 3600, "video_capture_maximum_clips": 4, "video_capture_maximum_bytes": 64 * 1024 * 1024, "video_capture_retained_maximum_bytes": 256 * 1024 * 1024, "video_capture_chunk_maximum_bytes": 65536, "video_capture_guest_only": true, "video_capture_optional_audio": true, "video_capture_ui_cues": false, "audio_capture": playtestsApproved, "audio_capture_maximum_fields": 120, "audio_capture_maximum_clips": 16, "audio_capture_maximum_bytes": 4 * 1024 * 1024, "build_diagnostics": true, "project_refresh": true, "input_status": refreshProblem ?? "approved", "changed_input_paths": Array(observedInputChanges.prefix(128)).map(\.path), "changed_input_paths_total": observedInputChanges.count, "changed_input_paths_truncated": observedInputChanges.count > 128, "kind": "cmoc", "app": "VCC Plus OSS",
"mutation_request_limit": MCPPlaytest.mutationRequestLimit, "stop_retention_exempt": true,
"playtest_processors": playtestsApproved ? ["MC6809", "HD6309"] : [],
"playtest_default_processor": "MC6809", "playtest_processor_selection": playtestsApproved,
"app_version": Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "unknown",
"app_build": Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "unknown", "project_id": id, "revision": revision,
"entry": scope.entry, "target": "CoCo Disk BASIC", "build_recipe": scope.customMake ? "approved_make" : scope.helloDisk ? "installed_hello_disk" : "bundled_cmoc", "files": scope.paths, "headers": Self.headers, "session_id": owner.uuidString, "version": 1]
"entry": scope.entry, "target": "CoCo Disk BASIC", "build_recipe": scope.customMake ? "approved_make" : scope.helloDisk ? "installed_hello_disk" : "bundled_cmoc", "files": scope.paths, "headers": Self.headers, "session_id": owner.uuidString, "version": 1,
"banked_debug_manifest_versions": [1, 2], "verified_code_overlays": true,
"overlay_residency_evidence": "complete_mapped_code_bytes"]
if scope.customMake {
var facts = result
facts["recipe_id"] = approvedRecipeID
@@ -832,7 +834,7 @@ final class MCPCMOC: ObservableObject {
case "start_playtest":
guard playtestsApproved else { throw problem("access_denied") }
result = try await startPlaytest(args, model: model, owner: owner)
case "playtest_input", "get_playtest_input", "playtest_debug", "capture_playtest", "capture_playtest_graphics", "capture_playtest_audio", "restart_playtest", "stop_playtest", "exchange_playtest_media":
case "playtest_input", "get_playtest_input", "playtest_debug", "capture_playtest", "capture_playtest_graphics", "capture_playtest_audio", "start_playtest_video", "stop_playtest_video", "read_playtest_video", "restart_playtest", "stop_playtest", "exchange_playtest_media":
if tool == "stop_playtest", playtestsApproved, args.count == 2,
let runID = args["run_id"] as? String, let request = args["request_id"] as? String,
(1...128).contains(request.utf8.count),
@@ -848,7 +850,7 @@ final class MCPCMOC: ObservableObject {
owned.artifactID == artifact.value.id.uuidString, !playtestBusy else { throw problem("stale_run") }
playtestBusy = true
defer { playtestBusy = false }
if !["capture_playtest", "capture_playtest_graphics", "get_playtest_input"].contains(tool) { ownedInspection = nil }
if !["capture_playtest", "capture_playtest_graphics", "get_playtest_input", "start_playtest_video", "stop_playtest_video", "read_playtest_video"].contains(tool) { ownedInspection = nil }
var request = args
if tool == "playtest_debug" {
guard Set(args.keys).isSubset(of: ["run_id", "request_id", "action", "function", "stop_kind"]), let action = args["action"] as? String else { throw problem("invalid_arguments") }
@@ -1070,8 +1072,12 @@ final class MCPCMOC: ObservableObject {
modules = layout.modules.compactMap { module in
let code = module.codeGuards
guard !code.isEmpty else { return nil }
return ["id": module.id, "pages": module.pages.map { ["logical_page": $0.logicalPage, "physical_page": $0.physicalPage] },
var definition: [String: Any] = ["id": module.id, "pages": module.pages.map { ["logical_page": $0.logicalPage, "physical_page": $0.physicalPage] },
"guards": code.map { ["address": Int($0.address), "bytes_base64": Data($0.bytes).base64EncodedString()] }]
if let overlay = module.overlay {
definition["overlay_group"] = overlay.group; definition["overlay_owner"] = overlay.owner
}
return definition
}
} else {
flatGuards = map.flatCodeGuards.map(\.workerFields)
@@ -1215,15 +1221,16 @@ final class MCPCMOC: ObservableObject {
guard ownsPlaytest(owned, artifact: artifact, owner: owner),
capture["processor"] as? String == owned.processor.rawValue,
capture["paused"] as? Bool == true, capture["attached"] as? Bool == true,
let clock = capture["field_clock"] as? Int else { throw problem("verified_pause_required") }
let clock = capture["field_clock"] as? Int,
let captureFingerprint = Self.ownedCaptureFingerprint(capture) else { throw problem("verified_pause_required") }
if tool == "get_call_context" {
guard callContextApproved, Set(arguments.keys) == ["run_id", "snapshot_id"],
let previous = ownedInspection, previous.run == owned.runID,
arguments["snapshot_id"] as? String == previous.id,
previous.clock == clock, previous.fingerprint == Self.ownedCaptureFingerprint(capture),
previous.clock == clock, previous.fingerprint == captureFingerprint,
var context = previous.callContext else { throw problem("stale_or_unavailable_call_context") }
for key in ["run_id", "snapshot_id", "artifact_id", "project_id", "revision", "processor", "requested_processor",
"execution_mode", "md_register", "field_clock", "boot", "stop_kind", "mapping_fingerprint", "program_revision"] {
"execution_mode", "md_register", "field_clock", "boot", "stop_kind", "mapping_fingerprint", "program_revision", "residency_fingerprint", "overlay_residency"] {
context[key] = previous.fields[key] ?? NSNull()
}
return context
@@ -1231,6 +1238,7 @@ final class MCPCMOC: ObservableObject {
if tool == "read_debug_memory" {
guard arguments.count == 4, let previous = ownedInspection, previous.run == owned.runID,
previous.clock == clock, arguments["snapshot_id"] as? String == previous.id,
previous.fingerprint == captureFingerprint,
let address = int(arguments["address"]), let count = int(arguments["count"]),
(1...256).contains(count), address >= 0, address <= 0xff00 - count,
previous.ranges.contains(where: { $0.contains(address) && address + count <= $0.upperBound }) else { throw problem("stale_or_unavailable_memory") }
@@ -1249,6 +1257,10 @@ final class MCPCMOC: ObservableObject {
let (verifiedMap, verifiedMetadata, variableError) = try await debugMetadata(artifact)
guard ownsPlaytest(owned, artifact: artifact, owner: owner) else { throw problem("stale_run") }
let map = verifiedMap.projected(physicalPages: pages, memory: memory, available: available)
if verifiedMap.bankedLayout?.overlayGroups.isEmpty == false {
guard let residency = capture["residency_fingerprint"] as? String, UInt64(residency) != nil,
residency != "0" else { throw problem("overlay_residency_unavailable") }
}
let metadata = verifiedMetadata?.projected(physicalPages: pages, memory: memory, available: available)
let shared = Set(scope?.paths ?? [])
let point = map.instruction(at: address).flatMap { shared.contains($0.sourcePath) ? $0 : nil }
@@ -1328,6 +1340,16 @@ final class MCPCMOC: ObservableObject {
"globals": globals.items, "globals_total": globals.total, "globals_truncated": globals.truncated,
"mapping_fingerprint": capture["mapping_fingerprint"] as Any? ?? NSNull(),
"program_revision": capture["program_revision"] as Any? ?? NSNull(),
"residency_fingerprint": capture["residency_fingerprint"] as Any? ?? "0",
"overlay_residency": map.bankedLayout?.overlayGroups.map { group in
let activeOwners = Set(map.bankedLayout!.modules.compactMap { module -> String? in
guard map.activeModuleIDs?.contains(module.id) == true, let overlay = module.overlay,
overlay.group == group.id else { return nil }
return overlay.owner
})
return ["group": group.id, "owner": activeOwners.count == 1 ? activeOwners.first! as Any : NSNull(),
"status": activeOwners.count == 1 ? "verified" : "unavailable"] as [String: Any]
} ?? [],
"physical_pages": rawPages,
"symbol_stop": symbols.count == 1 ? symbolCatalog.items.first as Any? ?? NSNull() : NSNull(),
"symbols_at_pc": symbolCatalog.items, "symbols_at_pc_total": symbolCatalog.total, "symbols_at_pc_truncated": symbolCatalog.truncated,
@@ -1335,11 +1357,10 @@ final class MCPCMOC: ObservableObject {
"source_debugging": ["status": metadata == nil ? "source_only" : "verified", "source_map": "verified", "variables": metadata == nil ? "unavailable" : "verified"],
"watch_status": metadata == nil ? String((variableError ?? "Typed C metadata is unavailable; verified code inspection remains available.").prefix(2000)) : "Verified globals; C frame locals are unavailable for owned entry and instruction stops.",
"memory_ranges": ranges.map { ["address": $0.lowerBound, "count": $0.count] }]
guard let fingerprint = Self.ownedCaptureFingerprint(capture) else { throw problem("invalid_worker_capture") }
let context = callContextApproved ? CMOCOwnedCallContext.capture(map: map, metadata: metadata, pc: address,
s: stackPointer, u: framePointer, memory: memory, available: available,
physicalPages: pages, sharedPaths: shared) : nil
ownedInspection = (snapshot, owned.runID, clock, memory, ranges, fields, fingerprint, context)
ownedInspection = (snapshot, owned.runID, clock, memory, ranges, fields, captureFingerprint, context)
return fields
}
@@ -1351,6 +1372,7 @@ final class MCPCMOC: ObservableObject {
guard keys.allSatisfy({ capture[$0] != nil }) else { return nil }
var state = Dictionary(uniqueKeysWithValues: keys.map { ($0, capture[$0]!) })
state["md_register"] = capture["md_register"] ?? NSNull()
state["residency_fingerprint"] = capture["residency_fingerprint"] ?? "0"
guard JSONSerialization.isValidJSONObject(state),
let bytes = try? JSONSerialization.data(withJSONObject: state, options: [.sortedKeys]) else { return nil }
return CMOCSourceMap.sha256(bytes)
@@ -1850,7 +1872,7 @@ private struct MCPCMOCConsent: View {
if !host.active {
Toggle("Allow Disposable Playtests", isOn: $host.allowPlaytests)
if host.allowPlaytests {
Text("Allow the assistant to launch this project's built disk or resume a retained test disk in a separate 512 KB 6809 or 6309 CoCo, hold key combinations and standard joystick axes and buttons, read input diagnostics, capture its screen, declared graphics buffers and guest audio, inspect verified program stops and shared data, read up to 64 bytes at the paused test guest’s stack pointer with caller and argument interpretations only when verified, and restart its own writable test disks. Reviewed additional disk products can be inserted or ejected in the paused, idle test drive without a reset or advancing time; each private writable copy is retained. The guest controls 6309 execution mode. Audio capture advances the test guest and uses no microphone. Retained originals and your current CoCo and media are preserved. Access ends when this connection or build changes.").font(.callout)
Text("Allow the assistant to launch this project's built disk or resume a retained test disk in a separate 512 KB 6809 or 6309 CoCo, hold key combinations and standard joystick axes and buttons, read input diagnostics, capture its screen, declared graphics buffers and guest audio, record bounded MP4 gameplay clips with optional CoCo audio, inspect verified program stops and shared data, read up to 64 bytes at the paused test guest’s stack pointer with caller and argument interpretations only when verified, and restart its own writable test disks. Reviewed additional disk products can be inserted or ejected in the paused, idle test drive without a reset or advancing time; each private writable copy is retained. The guest controls 6309 execution mode. Audio capture advances the test guest. Mac windows, microphone and capture feedback cues are excluded. Retained originals and your current CoCo and media are preserved. Access ends when this connection or build changes.").font(.callout)
}
if host.allowPlaytests, let media = model.project?.configuration.playtestDisks, !media.isEmpty {
Text("Additional playtest disks: " + media.joined(separator: ", ")).font(.callout).textSelection(.enabled)