Sync source edition with VCC Plus 3.7.0 build 63
This commit is contained in:
1 parent
c652a5276d
commit
b2ecec4d87
86 files changed
+10519
-472
No files matched your search
@@ -156,11 +156,14 @@ final class MCPCallContextAccessTests: XCTestCase {
|
||||
do {
|
||||
try await host.exportCallContextRegression(model, at: grantFile, helperURL: worker, roms: roms)
|
||||
let grant = try readGrant(grantFile)
|
||||
XCTAssertEqual(grant["toolset"] as? Int, 11)
|
||||
XCTAssertEqual(grant["toolset"] as? Int, 12)
|
||||
XCTAssertEqual(grant["playtestVideo"] as? Bool, true)
|
||||
XCTAssertEqual(grant["playtestCallContext"] as? Bool, true)
|
||||
let capabilities = try await result("get_capabilities", grant: grant)
|
||||
XCTAssertTrue((capabilities["tools"] as? [String])?.contains("get_call_context") == true)
|
||||
XCTAssertEqual(capabilities["call_context"] as? Bool, true)
|
||||
XCTAssertEqual(capabilities["banked_debug_manifest_versions"] as? [Int], [1, 2])
|
||||
XCTAssertEqual(capabilities["verified_code_overlays"] as? Bool, true)
|
||||
XCTAssertTrue((capabilities["build_actions"] as? [String])?.contains("disk") == true)
|
||||
XCTAssertTrue((capabilities["configurations"] as? [String])?.contains("Debug") == true)
|
||||
let scope: [String: Any] = ["project_id": try XCTUnwrap(capabilities["project_id"] as? String),
|
||||
@@ -176,6 +179,12 @@ final class MCPCallContextAccessTests: XCTestCase {
|
||||
XCTAssertEqual(running["run_id"] as? String, run)
|
||||
let snapshot = try await result("get_debug_snapshot", ["run_id": run], grant: grant)
|
||||
let snapshotID = try XCTUnwrap(snapshot["snapshot_id"] as? String)
|
||||
XCTAssertEqual(snapshot["residency_fingerprint"] as? String, "0", "Ordinary flat runs retain their existing identity")
|
||||
let range = try XCTUnwrap((snapshot["memory_ranges"] as? [[String: Int]])?.first)
|
||||
let memoryArguments: [String: Any] = ["run_id": run, "snapshot_id": snapshotID,
|
||||
"address": try XCTUnwrap(range["address"]), "count": min(8, try XCTUnwrap(range["count"]))]
|
||||
let frozenRead = try await result("read_debug_memory", memoryArguments, grant: grant)
|
||||
XCTAssertFalse((frozenRead["bytes"] as? [Int] ?? []).isEmpty)
|
||||
let arguments: [String: Any] = ["run_id": run, "snapshot_id": snapshotID]
|
||||
let context = try await result("get_call_context", arguments, grant: grant)
|
||||
XCTAssertEqual(context["run_id"] as? String, run)
|
||||
@@ -203,6 +212,8 @@ final class MCPCallContextAccessTests: XCTestCase {
|
||||
let repeated = try await result("get_call_context", arguments, grant: grant)
|
||||
XCTAssertEqual(repeated as NSDictionary, context as NSDictionary,
|
||||
"Repeated context reads preserve clock, registers, mapping and snapshot identity.")
|
||||
let memoryRead = try await result("read_debug_memory", memoryArguments, grant: grant)
|
||||
XCTAssertEqual(memoryRead as NSDictionary, frozenRead as NSDictionary)
|
||||
}
|
||||
for invalid in [arguments.merging(["run_id": "ordinary-shared-run"]) { _, new in new },
|
||||
arguments.merging(["snapshot_id": "stale-snapshot"]) { _, new in new },
|
||||
@@ -213,11 +224,78 @@ final class MCPCallContextAccessTests: XCTestCase {
|
||||
_ = try await result("playtest_debug", ["run_id": run, "request_id": UUID().uuidString, "action": "step"], grant: grant)
|
||||
let staleAfterStep = try await request("get_call_context", arguments, grant: grant)
|
||||
XCTAssertNotNil(staleAfterStep["error"])
|
||||
let staleMemory = try await request("read_debug_memory", memoryArguments, grant: grant)
|
||||
XCTAssertNotNil(staleMemory["error"])
|
||||
let newer = try await result("get_debug_snapshot", ["run_id": run], grant: grant)
|
||||
let newerArguments: [String: Any] = ["run_id": run, "snapshot_id": try XCTUnwrap(newer["snapshot_id"] as? String)]
|
||||
_ = try await build(scope, grant: grant)
|
||||
let latestArtifact = try await build(scope, grant: grant)
|
||||
let staleAfterBuild = try await request("get_call_context", newerArguments, grant: grant)
|
||||
XCTAssertNotNil(staleAfterBuild["error"])
|
||||
// Exercise the real stdio public schema and authenticated app host,
|
||||
// not a fixture host returning a manufactured MP4 response.
|
||||
let helper = Bundle(for: Self.self).bundleURL.deletingLastPathComponent().appendingPathComponent("vcc-mcp")
|
||||
let clientSource = resources.deletingLastPathComponent().appendingPathComponent("Tools/MCP/test-helper.py")
|
||||
var selection = scope; selection["artifact_id"] = try XCTUnwrap(latestArtifact["artifact_id"] as? String)
|
||||
let selectionJSON = String(decoding: try JSONSerialization.data(withJSONObject: selection), as: UTF8.self)
|
||||
let movie = root.appendingPathComponent("PublicVideo.mp4")
|
||||
let script = """
|
||||
import base64,hashlib,importlib.util,json,pathlib,sys,time,uuid
|
||||
spec=importlib.util.spec_from_file_location('mcp_fixture',sys.argv[1])
|
||||
fixture=importlib.util.module_from_spec(spec);spec.loader.exec_module(fixture)
|
||||
selection=json.loads(sys.argv[4])
|
||||
with fixture.Client(sys.argv[2],sys.argv[3]) as client:
|
||||
client.handshake('2025-06-18')
|
||||
def call(name,**args):
|
||||
result=client.call(name,**args)['result']
|
||||
assert not result.get('isError'), result
|
||||
return result['structuredContent']
|
||||
run=call('start_playtest',**selection,request_id=str(uuid.uuid4()))['run_id']
|
||||
scope={k:selection[k] for k in ('project_id','revision')}
|
||||
deadline=time.monotonic()+60
|
||||
while True:
|
||||
ready=call('get_run',**scope)
|
||||
if ready['status']!='starting':
|
||||
assert ready['status']=='ready', ready
|
||||
break
|
||||
assert time.monotonic()<deadline
|
||||
time.sleep(.025)
|
||||
started=call('start_playtest_video',run_id=run,request_id='begin-public-video',include_audio=False,max_fields=60)
|
||||
advanced=call('playtest_input',run_id=run,request_id='public-video-input',steps=[{'keys':[],'fields':30}])
|
||||
stopped=call('stop_playtest_video',run_id=run,request_id='end-public-video')
|
||||
clip=stopped['video']; assert clip['completed'] and clip['fields_recorded']==30, clip
|
||||
assert stopped['field_clock']==advanced['field_clock']
|
||||
data=bytearray();offset=0
|
||||
while True:
|
||||
page=call('read_playtest_video',run_id=run,clip_id=clip['clip_id'],offset=offset,limit=65536)
|
||||
data.extend(base64.b64decode(page['video_chunk_base64'],validate=True));offset=page['next_offset']
|
||||
if page['eof']:break
|
||||
assert len(data)==clip['byte_count'] and hashlib.sha256(data).hexdigest()==clip['sha256']
|
||||
assert data[4:8]==b'ftyp'
|
||||
pathlib.Path(sys.argv[5]).write_bytes(data)
|
||||
retained=call('stop_playtest',run_id=run,request_id='public-video-cleanup')
|
||||
assert retained['disk_retained']
|
||||
print(json.dumps({'bytes':len(data),'sha256':clip['sha256'],'fields':clip['fields_recorded']}))
|
||||
"""
|
||||
let publicOutput = try await Task.detached {
|
||||
let process = Process(), pipe = Pipe()
|
||||
process.executableURL = URL(fileURLWithPath: "/usr/bin/env")
|
||||
process.arguments = ["python3", "-c", script, clientSource.path, helper.path, grantFile.path, selectionJSON, movie.path]
|
||||
process.standardOutput = pipe; process.standardError = pipe
|
||||
let deadline = DispatchWorkItem { if process.isRunning { process.terminate() } }
|
||||
DispatchQueue.global().asyncAfter(deadline: .now() + 90, execute: deadline)
|
||||
defer { deadline.cancel() }
|
||||
try process.run()
|
||||
let output = try pipe.fileHandleForReading.readToEnd() ?? Data()
|
||||
process.waitUntilExit()
|
||||
guard process.terminationStatus == 0 else {
|
||||
throw NSError(domain: "MCPPublicVideo", code: Int(process.terminationStatus),
|
||||
userInfo: [NSLocalizedDescriptionKey: String(decoding: output, as: UTF8.self)])
|
||||
}
|
||||
return output
|
||||
}.value
|
||||
let publicVideo = try XCTUnwrap(JSONSerialization.jsonObject(with: publicOutput) as? [String: Any])
|
||||
XCTAssertEqual(publicVideo["fields"] as? Int, 30)
|
||||
XCTAssertEqual(publicVideo["sha256"] as? String, CMOCProject.sha256(try Data(contentsOf: movie)))
|
||||
await host.revoke().value
|
||||
XCTAssertFalse(FileManager.default.fileExists(atPath: grantFile.path))
|
||||
// A fresh endpoint lets us check the revoked token itself, rather
|
||||
@@ -292,7 +370,7 @@ final class MCPCallContextAccessTests: XCTestCase {
|
||||
}.value
|
||||
let observed = try XCTUnwrap(JSONSerialization.jsonObject(with: output) as? [String: Any])
|
||||
let names = try XCTUnwrap(observed["tools"] as? [String])
|
||||
XCTAssertEqual(names.count, 32)
|
||||
XCTAssertEqual(names.count, 35)
|
||||
XCTAssertTrue(names.contains("list_playtest_media")); XCTAssertTrue(names.contains("exchange_playtest_media"))
|
||||
XCTAssertEqual(Set(names), Set(try XCTUnwrap(observed["host_tools"] as? [String])))
|
||||
XCTAssertEqual(observed["media"] as? Bool, true)
|
||||
@@ -391,11 +469,12 @@ final class MCPCallContextAccessTests: XCTestCase {
|
||||
do {
|
||||
try await host.exportCallContextRegression(model, at: grantFile, helperURL: worker, roms: roms)
|
||||
let grant = try readGrant(grantFile)
|
||||
XCTAssertEqual(grant["toolset"] as? Int, 11)
|
||||
XCTAssertEqual(grant["toolset"] as? Int, 12)
|
||||
XCTAssertEqual(grant["playtestVideo"] as? Bool, true)
|
||||
XCTAssertEqual(grant["playtestMedia"] as? Bool, true)
|
||||
let capabilities = try await result("get_capabilities", grant: grant)
|
||||
XCTAssertEqual(capabilities["playtest_media_exchange"] as? Bool, true)
|
||||
XCTAssertEqual((capabilities["tools"] as? [String])?.count, 32)
|
||||
XCTAssertEqual((capabilities["tools"] as? [String])?.count, 35)
|
||||
let scope: [String: Any] = ["project_id": try XCTUnwrap(capabilities["project_id"] as? String),
|
||||
"revision": try XCTUnwrap(capabilities["revision"] as? Int)]
|
||||
let artifact = try await build(scope, grant: grant)
|
||||
|
||||
Reference in new issue
Block a user