personal memory agent
0

Configure Feed

Select the types of activity you want to include in your feed.

fix(release): accept real macOS swift --version banner shapes

parse_macos_swift_banner rejected the real host output: swift --version emits two lines with trailing `Target: arm64-apple-macosx26.0`, and the macOS build-host channel adapter flattens them with `tr '\n' ' '` into one line ending in ` Target: ...`. Both forms were refused, failing a correctly pinned host.

Extend `_MACOS_SWIFT_BANNER_RE` with an optional trailing `Target: <token>` segment using a single space or single newline separator. Continue parsing only the `(version, swiftlang, clang)` triple and comparing it against the unchanged `MACOS_SWIFT_PIN`. `parse_macos_swift_banner` now fullmatches the raw value, and the swift dispatch in `parse_host_variant_tool_banner` moves above the single-line gate. The uv path is untouched.

Add `MACOS_SWIFT_TARGET_LINE`, `MACOS_SWIFT_RAW_BANNER`, and `MACOS_SWIFT_FLATTENED_BANNER` fixtures derived from the byte-identical `MACOS_SWIFT_FIXTURE_BANNER`. No pin values change.

Tests move the raw two-line case to accepts, add direct parser red-proofs for both real forms plus a mutation-still-refused check, and make the channel-adapter boundary fake emit the real flattened-with-Target output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

+58 -11
+7 -7
scripts/release_tool_pins.py
··· 52 52 "Apple Swift version 6.3.3 " 53 53 "(swiftlang-6.3.3.1.3 clang-2100.1.1.101)" 54 54 ) 55 + MACOS_SWIFT_TARGET_LINE = "Target: arm64-apple-macosx26.0" 56 + MACOS_SWIFT_RAW_BANNER = f"{MACOS_SWIFT_FIXTURE_BANNER}\n{MACOS_SWIFT_TARGET_LINE}" 57 + MACOS_SWIFT_FLATTENED_BANNER = f"{MACOS_SWIFT_FIXTURE_BANNER} {MACOS_SWIFT_TARGET_LINE}" 55 58 MACOS_CODESIGN_PATH = "/usr/bin/codesign" 56 59 MACOS_CODESIGN_PUBLIC_PIN = "codesign pinned-path verified" 57 60 # xcrun notarytool --version prints the bare grounded output, with no tool prefix. ··· 69 72 r"^(?:swift-driver version: (?P<driver>\d+(?:\.\d+){2}) )?" 70 73 r"Apple Swift version (?P<version>\d+(?:\.\d+){2}) " 71 74 r"\(swiftlang-(?P<swiftlang>\d+(?:\.\d+){4}) " 72 - r"clang-(?P<clang>\d+(?:\.\d+){3})\)$" 75 + r"clang-(?P<clang>\d+(?:\.\d+){3})\)(?:[ \n]Target: \S+)?$" 73 76 ) 74 77 SwiftToolIdentity = tuple[str, str, str] 75 78 HostVariantToolIdentity = str | SwiftToolIdentity ··· 106 109 107 110 108 111 def parse_macos_swift_banner(value: str) -> SwiftToolIdentity | None: 109 - line = _single_stripped_line(value) 110 - if line is None: 111 - return None 112 - match = _MACOS_SWIFT_BANNER_RE.fullmatch(line) 112 + match = _MACOS_SWIFT_BANNER_RE.fullmatch(value) 113 113 if match is None: 114 114 return None 115 115 return (match["version"], match["swiftlang"], match["clang"]) ··· 118 118 def parse_host_variant_tool_banner( 119 119 tool: str, value: str 120 120 ) -> HostVariantToolIdentity | None: 121 + if tool == "swift": 122 + return parse_macos_swift_banner(value) 121 123 line = _single_stripped_line(value) 122 124 if line is None: 123 125 return None 124 - if tool == "swift": 125 - return parse_macos_swift_banner(line) 126 126 parts = line.split(" ", 2) 127 127 if len(parts) != 3: 128 128 return None
+3 -3
tests/test_channel_adapters.py
··· 23 23 from scripts.release_digest import candidate_digest 24 24 from scripts.release_tool_pins import ( 25 25 HOST_VARIANT_TOOL_KEYS, 26 - MACOS_SWIFT_FIXTURE_BANNER, 26 + MACOS_SWIFT_FLATTENED_BANNER, 27 27 UV_MACOS_FIXTURE_BANNER, 28 28 ) 29 29 ··· 93 93 observed = { 94 94 **expected, 95 95 "uv": uv, 96 - "swift": MACOS_SWIFT_FIXTURE_BANNER, 96 + "swift": MACOS_SWIFT_FLATTENED_BANNER, 97 97 } 98 98 return ( 99 99 "\n".join(f"{key}\t{observed[key]}" for key in sorted(observed)) ··· 448 448 449 449 assert set(evidence) == set(expected) 450 450 assert evidence["uv"] == UV_MACOS_FIXTURE_BANNER 451 - assert evidence["swift"] == MACOS_SWIFT_FIXTURE_BANNER 451 + assert evidence["swift"] == MACOS_SWIFT_FLATTENED_BANNER 452 452 for key in set(expected) - set(HOST_VARIANT_TOOL_KEYS): 453 453 assert evidence[key] == expected[key] 454 454
+38 -1
tests/test_check_release_preflight.py
··· 331 331 ( 332 332 pins.MACOS_SWIFT_FIXTURE_BANNER, 333 333 pins.MACOS_SWIFT_PIN, 334 + pins.MACOS_SWIFT_RAW_BANNER, 335 + pins.MACOS_SWIFT_FLATTENED_BANNER, 334 336 ), 335 337 ) 336 338 def test_host_variant_swift_evidence_accepts_strict_identity( ··· 349 351 350 352 351 353 @pytest.mark.parametrize( 354 + "swift_banner", 355 + ( 356 + pins.MACOS_SWIFT_RAW_BANNER, 357 + pins.MACOS_SWIFT_FLATTENED_BANNER, 358 + ), 359 + ) 360 + def test_parse_macos_swift_banner_accepts_real_host_forms( 361 + swift_banner: str, 362 + ) -> None: 363 + assert pins.parse_macos_swift_banner(swift_banner) == ( 364 + "6.3.3", 365 + "6.3.3.1.3", 366 + "2100.1.1.101", 367 + ) 368 + assert ( 369 + pins.check_host_variant_tool_pin("swift", pins.MACOS_SWIFT_PIN, swift_banner) 370 + is True 371 + ) 372 + 373 + 374 + def test_check_host_variant_swift_pin_rejects_mutated_flattened_identity() -> None: 375 + mutated = pins.MACOS_SWIFT_FLATTENED_BANNER.replace( 376 + "Apple Swift version 6.3.3", "Apple Swift version 6.3.4" 377 + ) 378 + assert pins.parse_macos_swift_banner(mutated) == ( 379 + "6.3.4", 380 + "6.3.3.1.3", 381 + "2100.1.1.101", 382 + ) 383 + assert ( 384 + pins.check_host_variant_tool_pin("swift", pins.MACOS_SWIFT_PIN, mutated) 385 + is False 386 + ) 387 + 388 + 389 + @pytest.mark.parametrize( 352 390 "swift_value", 353 391 ( 354 392 "not found", 355 393 "exit 1", 356 394 "", 357 395 " ", 358 - f"{pins.MACOS_SWIFT_FIXTURE_BANNER}\nTarget: arm64-apple-macosx26.0", 359 396 "swift 6.3.3", 360 397 "swift-driver 1.148.6 Apple Swift version 6.3.3 (swiftlang-6.3.3.1.3 clang-2100.1.1.101)", 361 398 f"{pins.MACOS_SWIFT_FIXTURE_BANNER} extra",
+10
tests/test_check_rust_release_manifest.py
··· 139 139 140 140 assert pins.MACOS_SWIFT_PIN == exact 141 141 assert checker.validate_public_evidence_text("swift", pins.MACOS_SWIFT_PIN) == [] 142 + assert ( 143 + checker.validate_public_evidence_text("swift", pins.MACOS_SWIFT_RAW_BANNER) 144 + == [] 145 + ) 146 + assert ( 147 + checker.validate_public_evidence_text( 148 + "swift", pins.MACOS_SWIFT_FLATTENED_BANNER 149 + ) 150 + == [] 151 + ) 142 152 assert not any( 143 153 line.startswith("MACOS_SWIFT_VERSION") 144 154 for line in Path(pins.__file__).read_text(encoding="utf-8").splitlines()