From c2f854bd6b6b19d5b7fbb7923cb9ea6b56c69a07 Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Tue, 29 Sep 2026 01:44:51 -0500 Subject: [PATCH 01/18] fix(vscode): admit exact RC manifest fallback --- editors/vscode/src/downloader.ts | 71 ++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/editors/vscode/src/downloader.ts b/editors/vscode/src/downloader.ts index 839dca424..b5c3bf0ca 100644 --- a/editors/vscode/src/downloader.ts +++ b/editors/vscode/src/downloader.ts @@ -159,22 +159,12 @@ async function downloadAdmittedAsset( progress: vscode.Progress<{ message?: string; increment?: number }> ): Promise { const expectedDigest = distribution.manifestSha256 as string; - const [preferred, ...fallbacks] = manifestCandidatesForDistribution(config.downloadBaseUrl, distribution, version); - let admitted: { manifest: AdmittedServerManifest; manifestUrl: string }; - try { - admitted = { - manifest: await fetchAdmittedManifest(preferred, expectedDigest), - manifestUrl: preferred - }; - } catch (error) { - const fallback = fallbacks[0]; - if (fallback === undefined || !isDirectManifestNotFound(error)) { - throw error; - } - throw new Error( - `Preferred placement manifest is unpublished and the fallback carries no admitted digest; refusing unadmitted fallback ${fallback}.` - ); - } + const admitted = await fetchAdmittedManifestForDistribution( + config.downloadBaseUrl, + distribution, + version, + expectedDigest + ); if (admitted.manifest.productVersion !== version) { throw new Error( `Admitted manifest product version ${admitted.manifest.productVersion} does not match requested version ${version}.` @@ -190,7 +180,54 @@ async function downloadAdmittedAsset( progress.report({ message: `Downloading ${platform.executableName}…` }); const { body: bytes } = await fetchBuffer(assetUrl, asset.archiveSize, fetchPolicyFor(assetUrl)); progress.report({ message: 'Verifying checksum…' }); - return { manifestVersion: admitted.manifest.productVersion, expectedSha256: asset.sha256, bytes, admittedManifestSha256: expectedDigest }; + return { + manifestVersion: admitted.manifest.productVersion, + expectedSha256: asset.sha256, + bytes, + admittedManifestSha256: expectedDigest, + selectedManifestUrl: admitted.manifestUrl + }; +} + +export type FetchAdmittedManifest = ( + url: string, + expectedDigest: string +) => Promise; + +export interface AdmittedManifestSelection { + readonly manifest: AdmittedServerManifest; + readonly manifestUrl: string; +} + +/** + * Fetches the descriptor-bound manifest from the preferred exact placement. + * Only an authoritative direct 404 may select the one predeclared fallback. + * Both placements are admitted against the same embedded manifest digest, so + * fallback changes the observed location without changing content authority. + */ +export async function fetchAdmittedManifestForDistribution( + baseUrl: string, + distribution: ResolvedDistributionRequest, + version: string, + expectedDigest: string, + fetchImpl: FetchAdmittedManifest = fetchAdmittedManifest +): Promise { + const [preferred, ...fallbacks] = manifestCandidatesForDistribution(baseUrl, distribution, version); + try { + return { + manifest: await fetchImpl(preferred, expectedDigest), + manifestUrl: preferred + }; + } catch (error) { + const fallback = fallbacks[0]; + if (fallback === undefined || !isDirectManifestNotFound(error)) { + throw error; + } + return { + manifest: await fetchImpl(fallback, expectedDigest), + manifestUrl: fallback + }; + } } export async function fetchAdmittedManifest(url: string, expectedDigest: string): Promise { From e00e98b3aeaf2127c330efa8f978e21ade8dcab1 Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Tue, 29 Sep 2026 01:45:05 -0500 Subject: [PATCH 02/18] fix(vscode): retain selected manifest observation --- editors/vscode/src/managedServerInstall.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/editors/vscode/src/managedServerInstall.ts b/editors/vscode/src/managedServerInstall.ts index ff594c255..8f3bb9904 100644 --- a/editors/vscode/src/managedServerInstall.ts +++ b/editors/vscode/src/managedServerInstall.ts @@ -25,6 +25,13 @@ export interface InstallReceiptV1 { * admitted under a different manifest cannot be reused. */ readonly manifestSha256?: string; + /** + * Exact manifest location observed when these bytes were admitted. + * This is provenance/observation evidence only: cache currentness remains + * bound to distributionIdentity + manifestSha256, so identical RC bytes are + * not redownloaded merely to relabel them as stable. + */ + readonly selectedManifestUrl?: string; /** * Placement-neutral identity of the distribution descriptor that produced * this install. Absent on legacy receipts; a distribution-bound request @@ -71,6 +78,11 @@ export interface ResolvedArchive { * the resolved distribution; the staged receipt binds to it below. */ readonly admittedManifestSha256?: string; + /** + * Exact manifest URL used to select this archive. Observation only; it is + * retained in the completed receipt but is deliberately not a cache key. + */ + readonly selectedManifestUrl?: string; } export interface ManagedServerInstallOperations { @@ -278,6 +290,9 @@ async function stageAndPromote( : {}), ...(resolved.admittedManifestSha256 !== undefined ? { manifestSha256: resolved.admittedManifestSha256 } + : {}), + ...(resolved.selectedManifestUrl !== undefined + ? { selectedManifestUrl: resolved.selectedManifestUrl } : {}) }; await fs.promises.rm(archivePath, { force: true }); From 43c1a01c9388ac6dd49834124cb568f7278b94ab Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Tue, 29 Sep 2026 01:45:30 -0500 Subject: [PATCH 03/18] test(vscode): pin admitted RC fallback law --- .../distribution_manifest_fallback.test.ts | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/editors/vscode/test/suite/distribution_manifest_fallback.test.ts b/editors/vscode/test/suite/distribution_manifest_fallback.test.ts index cf51e893e..fc7d50668 100644 --- a/editors/vscode/test/suite/distribution_manifest_fallback.test.ts +++ b/editors/vscode/test/suite/distribution_manifest_fallback.test.ts @@ -4,7 +4,9 @@ import { resolveDistributionRequest } from '../../src/distributionDescriptor'; import { + FetchAdmittedManifest, FetchManifest, + fetchAdmittedManifestForDistribution, fetchManifestForDistribution, isDirectManifestNotFound, ManifestFetchError, @@ -59,6 +61,112 @@ suite('Distribution manifest fallback', () => { ]); }); + test('admits the exact RC placement with the same embedded digest after direct stable 404', async () => { + const distribution = resolveDistributionRequest('0.11.0', { + ...catalog, + schema: 2, + distributionGeneration: 'a'.repeat(64), + manifestSha256: 'b'.repeat(64), + targetSetDigest: 'c'.repeat(64) + }); + const expectedDigest = distribution.manifestSha256 as string; + const requested: Array<[string, string]> = []; + const fetchImpl: FetchAdmittedManifest = async (url, digest) => { + requested.push([url, digest]); + if (requested.length === 1) { + throw notFound(url, false); + } + return { productVersion: '0.11.0', assets: {} } as never; + }; + + const result = await fetchAdmittedManifestForDistribution( + '', + distribution, + '0.11.0', + expectedDigest, + fetchImpl + ); + + assert.strictEqual( + result.manifestUrl, + 'https://github.com/EffortlessMetrics/ripr/releases/download/v0.11.0-rc.1/ripr-server-manifest-v0.11.0.json' + ); + assert.deepStrictEqual(requested, [ + [ + 'https://github.com/EffortlessMetrics/ripr/releases/download/v0.11.0/ripr-server-manifest-v0.11.0.json', + expectedDigest + ], + [ + 'https://github.com/EffortlessMetrics/ripr/releases/download/v0.11.0-rc.1/ripr-server-manifest-v0.11.0.json', + expectedDigest + ] + ]); + }); + + test('trusted manifest fallback propagates every non-authoritative absence unchanged', async () => { + const distribution = resolveDistributionRequest('0.11.0', { + ...catalog, + schema: 2, + distributionGeneration: 'a'.repeat(64), + manifestSha256: 'b'.repeat(64), + targetSetDigest: 'c'.repeat(64) + }); + const failures: Array<[string, unknown]> = [ + ['http 500', new ManifestFetchError('GET https://example.invalid/stable failed with HTTP 500.', { statusCode: 500, redirected: false })], + ['redirected 404', notFound('https://example.invalid/stable', true)], + ['transport', new Error('socket hang up')], + ['digest conflict', new Error('Server manifest SHA-256 does not match the admitted digest.')] + ]; + + for (const [name, failure] of failures) { + let calls = 0; + const fetchImpl: FetchAdmittedManifest = async () => { + calls += 1; + throw failure; + }; + await assert.rejects( + fetchAdmittedManifestForDistribution( + '', + distribution, + '0.11.0', + distribution.manifestSha256 as string, + fetchImpl + ), + (error: unknown) => error === failure, + name + ); + assert.strictEqual(calls, 1, `${name} must not reach the trusted fallback`); + } + }); + + test('trusted manifest fallback is disabled for an explicit mirror transport', async () => { + const distribution = resolveDistributionRequest('0.11.0', { + ...catalog, + schema: 2, + distributionGeneration: 'a'.repeat(64), + manifestSha256: 'b'.repeat(64), + targetSetDigest: 'c'.repeat(64) + }); + const failure = notFound('https://mirror.invalid/ripr/ripr-server-manifest-v0.11.0.json', false); + let calls = 0; + const fetchImpl: FetchAdmittedManifest = async () => { + calls += 1; + throw failure; + }; + + await assert.rejects( + fetchAdmittedManifestForDistribution( + 'https://mirror.invalid/ripr', + distribution, + '0.11.0', + distribution.manifestSha256 as string, + fetchImpl + ), + (error: unknown) => error === failure + ); + assert.strictEqual(calls, 1); + }); + test('propagates transport, server, redirect, and malformed failures without falling back', async () => { const distribution = resolveDistributionRequest('0.11.0', catalog); const failures: Array<[string, unknown]> = [ From 523a6b5acaf0918e1bd11eb38bd0b3920feb9865 Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Tue, 29 Sep 2026 01:45:46 -0500 Subject: [PATCH 04/18] test(vscode): retain manifest placement observation --- .../vscode/test/suite/managed_server_install.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/editors/vscode/test/suite/managed_server_install.test.ts b/editors/vscode/test/suite/managed_server_install.test.ts index e86fc7bc3..aa36802f9 100644 --- a/editors/vscode/test/suite/managed_server_install.test.ts +++ b/editors/vscode/test/suite/managed_server_install.test.ts @@ -43,16 +43,24 @@ suite('Managed Server Installation', () => { const digest = 'a'.repeat(64); const request: ManagedServerInstallRequest = { ...installRequest(root, '1.2.3'), expectedManifestSha256: digest }; const admitted = operations('binary-v1', '1.2.3'); + const selectedManifestUrl = + 'https://github.com/EffortlessMetrics/ripr/releases/download/v1.2.3-rc.1/ripr-server-manifest-v1.2.3.json'; const withStamp: ManagedServerInstallOperations = { ...admitted, - resolveArchive: async () => ({ ...(await admitted.resolveArchive()), admittedManifestSha256: digest }) + resolveArchive: async () => ({ + ...(await admitted.resolveArchive()), + admittedManifestSha256: digest, + selectedManifestUrl + }) }; const installed = await installManagedServer(request, withStamp); assert.strictEqual(installed.receipt.manifestSha256, digest); + assert.strictEqual(installed.receipt.selectedManifestUrl, selectedManifestUrl); const cached = await readManagedServerInstallation(request); assert.notStrictEqual(cached, undefined); assert.strictEqual(cached?.receipt.manifestSha256, digest); + assert.strictEqual(cached?.receipt.selectedManifestUrl, selectedManifestUrl); }); test('bound requests reject unstamped and mismatched receipts', async () => { From 678f9b0939140d286acd74fe160e41e2f0036783 Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Tue, 29 Sep 2026 02:04:06 -0500 Subject: [PATCH 05/18] fix(vscode): retain manifest placement observations --- editors/vscode/src/downloader.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/editors/vscode/src/downloader.ts b/editors/vscode/src/downloader.ts index b5c3bf0ca..d7d036070 100644 --- a/editors/vscode/src/downloader.ts +++ b/editors/vscode/src/downloader.ts @@ -185,7 +185,10 @@ async function downloadAdmittedAsset( expectedSha256: asset.sha256, bytes, admittedManifestSha256: expectedDigest, - selectedManifestUrl: admitted.manifestUrl + selectedManifestUrl: admitted.manifestUrl, + manifestSelection: admitted.manifestSelection, + preferredManifestObservation: admitted.preferredManifestObservation, + fallbackManifestObservation: admitted.fallbackManifestObservation }; } @@ -197,6 +200,9 @@ export type FetchAdmittedManifest = ( export interface AdmittedManifestSelection { readonly manifest: AdmittedServerManifest; readonly manifestUrl: string; + readonly manifestSelection: 'preferred_exact' | 'fallback_exact_after_preferred_absent'; + readonly preferredManifestObservation: 'accepted' | 'direct_not_found'; + readonly fallbackManifestObservation: 'not_requested' | 'accepted'; } /** @@ -216,7 +222,10 @@ export async function fetchAdmittedManifestForDistribution( try { return { manifest: await fetchImpl(preferred, expectedDigest), - manifestUrl: preferred + manifestUrl: preferred, + manifestSelection: 'preferred_exact', + preferredManifestObservation: 'accepted', + fallbackManifestObservation: 'not_requested' }; } catch (error) { const fallback = fallbacks[0]; @@ -225,7 +234,10 @@ export async function fetchAdmittedManifestForDistribution( } return { manifest: await fetchImpl(fallback, expectedDigest), - manifestUrl: fallback + manifestUrl: fallback, + manifestSelection: 'fallback_exact_after_preferred_absent', + preferredManifestObservation: 'direct_not_found', + fallbackManifestObservation: 'accepted' }; } } From 9684b48ef1a7cce0f2b7adb3bc301864d40ff885 Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Tue, 29 Sep 2026 02:04:25 -0500 Subject: [PATCH 06/18] fix(vscode): bind placement observation to install receipt --- editors/vscode/src/managedServerInstall.ts | 37 +++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/editors/vscode/src/managedServerInstall.ts b/editors/vscode/src/managedServerInstall.ts index 8f3bb9904..b6a26bea3 100644 --- a/editors/vscode/src/managedServerInstall.ts +++ b/editors/vscode/src/managedServerInstall.ts @@ -8,6 +8,10 @@ const LOCK_POLL_MS = 50; const LOCK_HEARTBEAT_MS = 30_000; const MANAGED_VERSION_PATTERN = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/; +export type ManagedManifestSelection = 'preferred_exact' | 'fallback_exact_after_preferred_absent'; +export type PreferredManifestObservation = 'accepted' | 'direct_not_found'; +export type FallbackManifestObservation = 'not_requested' | 'accepted'; + export interface InstallReceiptV1 { readonly schemaVersion: 1; readonly installationState: 'complete'; @@ -32,6 +36,9 @@ export interface InstallReceiptV1 { * not redownloaded merely to relabel them as stable. */ readonly selectedManifestUrl?: string; + readonly manifestSelection?: ManagedManifestSelection; + readonly preferredManifestObservation?: PreferredManifestObservation; + readonly fallbackManifestObservation?: FallbackManifestObservation; /** * Placement-neutral identity of the distribution descriptor that produced * this install. Absent on legacy receipts; a distribution-bound request @@ -83,6 +90,9 @@ export interface ResolvedArchive { * retained in the completed receipt but is deliberately not a cache key. */ readonly selectedManifestUrl?: string; + readonly manifestSelection?: ManagedManifestSelection; + readonly preferredManifestObservation?: PreferredManifestObservation; + readonly fallbackManifestObservation?: FallbackManifestObservation; } export interface ManagedServerInstallOperations { @@ -96,6 +106,10 @@ export interface ManagedServerInstallOperations { export interface ManagedServerReceiptIdentity { readonly assetDigest: string; readonly installationState: 'complete'; + readonly selectedManifestUrl?: string; + readonly manifestSelection?: ManagedManifestSelection; + readonly preferredManifestObservation?: PreferredManifestObservation; + readonly fallbackManifestObservation?: FallbackManifestObservation; } export function validateManagedServerVersion(version: string): string { @@ -114,7 +128,19 @@ export function combineActiveManagedServerIdentity Date: Tue, 29 Sep 2026 02:04:43 -0500 Subject: [PATCH 07/18] fix(vscode): surface exact manifest placement --- editors/vscode/src/serverResolver.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/editors/vscode/src/serverResolver.ts b/editors/vscode/src/serverResolver.ts index 42b718789..edb5ad56d 100644 --- a/editors/vscode/src/serverResolver.ts +++ b/editors/vscode/src/serverResolver.ts @@ -340,7 +340,27 @@ function withManagedIdentity( resolved: ResolvedServer, installation: ManagedServerInstallation ): ResolvedServer { - return combineActiveManagedServerIdentity(resolved, installation); + const combined = combineActiveManagedServerIdentity(resolved, installation); + const placement = managedManifestPlacementDetail(installation); + return placement === undefined + ? combined + : { ...combined, detail: `${combined.detail}; ${placement}` }; +} + +export function managedManifestPlacementDetail( + installation: ManagedServerInstallation +): string | undefined { + const receipt = installation.receipt; + if ( + receipt.manifestSelection === undefined || + receipt.selectedManifestUrl === undefined + ) { + return undefined; + } + if (receipt.manifestSelection === 'preferred_exact') { + return `manifest placement: preferred exact (${receipt.selectedManifestUrl}); preferred=accepted; fallback=not requested`; + } + return `manifest placement: exact fallback after preferred absence (${receipt.selectedManifestUrl}); preferred=direct 404; fallback=accepted`; } function isResolved(result: ResolvedServer | ResolveFailure): result is ResolvedServer { From 73ae0e6afeab06e036487731b2a7bbf950e58af6 Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Tue, 29 Sep 2026 02:05:11 -0500 Subject: [PATCH 08/18] test(vscode): retain trusted placement observations --- .../vscode/test/suite/distribution_manifest_fallback.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/editors/vscode/test/suite/distribution_manifest_fallback.test.ts b/editors/vscode/test/suite/distribution_manifest_fallback.test.ts index fc7d50668..1292af581 100644 --- a/editors/vscode/test/suite/distribution_manifest_fallback.test.ts +++ b/editors/vscode/test/suite/distribution_manifest_fallback.test.ts @@ -91,6 +91,9 @@ suite('Distribution manifest fallback', () => { result.manifestUrl, 'https://github.com/EffortlessMetrics/ripr/releases/download/v0.11.0-rc.1/ripr-server-manifest-v0.11.0.json' ); + assert.strictEqual(result.manifestSelection, 'fallback_exact_after_preferred_absent'); + assert.strictEqual(result.preferredManifestObservation, 'direct_not_found'); + assert.strictEqual(result.fallbackManifestObservation, 'accepted'); assert.deepStrictEqual(requested, [ [ 'https://github.com/EffortlessMetrics/ripr/releases/download/v0.11.0/ripr-server-manifest-v0.11.0.json', From 71c146f781d5aee4aa4e7a6256dfce9c7a5e1dba Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Tue, 29 Sep 2026 02:05:15 -0500 Subject: [PATCH 09/18] test(vscode): prove placement evidence stays outside cache identity --- .../test/suite/managed_server_install.test.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/editors/vscode/test/suite/managed_server_install.test.ts b/editors/vscode/test/suite/managed_server_install.test.ts index aa36802f9..680f9ceb5 100644 --- a/editors/vscode/test/suite/managed_server_install.test.ts +++ b/editors/vscode/test/suite/managed_server_install.test.ts @@ -50,17 +50,32 @@ suite('Managed Server Installation', () => { resolveArchive: async () => ({ ...(await admitted.resolveArchive()), admittedManifestSha256: digest, - selectedManifestUrl + selectedManifestUrl, + manifestSelection: 'fallback_exact_after_preferred_absent', + preferredManifestObservation: 'direct_not_found', + fallbackManifestObservation: 'accepted' }) }; const installed = await installManagedServer(request, withStamp); assert.strictEqual(installed.receipt.manifestSha256, digest); assert.strictEqual(installed.receipt.selectedManifestUrl, selectedManifestUrl); + assert.strictEqual(installed.receipt.manifestSelection, 'fallback_exact_after_preferred_absent'); + assert.strictEqual(installed.receipt.preferredManifestObservation, 'direct_not_found'); + assert.strictEqual(installed.receipt.fallbackManifestObservation, 'accepted'); const cached = await readManagedServerInstallation(request); assert.notStrictEqual(cached, undefined); assert.strictEqual(cached?.receipt.manifestSha256, digest); assert.strictEqual(cached?.receipt.selectedManifestUrl, selectedManifestUrl); + assert.strictEqual(cached?.receipt.manifestSelection, 'fallback_exact_after_preferred_absent'); + assert.strictEqual(cached?.receipt.preferredManifestObservation, 'direct_not_found'); + assert.strictEqual(cached?.receipt.fallbackManifestObservation, 'accepted'); + + const combined = combineActiveManagedServerIdentity({ binaryVersion: 'ripr active' }, installed); + assert.strictEqual(combined.selectedManifestUrl, selectedManifestUrl); + assert.strictEqual(combined.manifestSelection, 'fallback_exact_after_preferred_absent'); + assert.strictEqual(combined.preferredManifestObservation, 'direct_not_found'); + assert.strictEqual(combined.fallbackManifestObservation, 'accepted'); }); test('bound requests reject unstamped and mismatched receipts', async () => { From 2a71995ff814df362e6a195190bd4811fc1a3f8b Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Tue, 29 Sep 2026 02:05:32 -0500 Subject: [PATCH 10/18] test(vscode): surface selected manifest placement --- .../server_resolver_compatibility.test.ts | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/editors/vscode/test/suite/server_resolver_compatibility.test.ts b/editors/vscode/test/suite/server_resolver_compatibility.test.ts index bdfaf9b6d..8850f511c 100644 --- a/editors/vscode/test/suite/server_resolver_compatibility.test.ts +++ b/editors/vscode/test/suite/server_resolver_compatibility.test.ts @@ -5,10 +5,45 @@ import * as path from 'path'; import * as vscode from 'vscode'; import { RiprConfig } from '../../src/config'; import { currentRiprPlatform } from '../../src/platform'; -import { resolveServer, ServerResolverRuntime } from '../../src/serverResolver'; +import { ManagedServerInstallation } from '../../src/managedServerInstall'; +import { + managedManifestPlacementDetail, + resolveServer, + ServerResolverRuntime +} from '../../src/serverResolver'; import { compatibleLspEvidence } from './testCompatibility'; suite('Server resolver compatibility fallback', () => { + test('renders the exact managed manifest placement into user-visible server detail', () => { + const selectedManifestUrl = + 'https://github.com/EffortlessMetrics/ripr/releases/download/v0.11.0-rc.1/ripr-server-manifest-v0.11.0.json'; + const installation = { + executablePath: '/tmp/ripr', + receiptPath: '/tmp/install-receipt.json', + receipt: { + schemaVersion: 1, + installationState: 'complete', + requestedVersion: '0.11.0', + manifestVersion: '0.11.0', + platformTarget: 'x86_64-unknown-linux-gnu', + executableName: 'ripr', + archiveSha256: 'a'.repeat(64), + executableSha256: 'b'.repeat(64), + binaryVersion: 'ripr 0.11.0', + selectedManifestUrl, + manifestSelection: 'fallback_exact_after_preferred_absent', + preferredManifestObservation: 'direct_not_found', + fallbackManifestObservation: 'accepted' + } + } satisfies ManagedServerInstallation; + + const detail = managedManifestPlacementDetail(installation); + assert.ok(detail?.includes('exact fallback after preferred absence')); + assert.ok(detail?.includes(selectedManifestUrl)); + assert.ok(detail?.includes('preferred=direct 404')); + assert.ok(detail?.includes('fallback=accepted')); + }); + test('skips an incompatible bundled candidate and selects the next allowed channel', async function () { const platform = currentRiprPlatform(); if (!platform) { From 0428f1c652854133905b9aff70dc117d6a9c2812 Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Fri, 2 Oct 2026 22:13:18 -0400 Subject: [PATCH 11/18] test(vscode): exercise RC fallback through real manifest admission --- .../distribution_manifest_fallback.test.ts | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/editors/vscode/test/suite/distribution_manifest_fallback.test.ts b/editors/vscode/test/suite/distribution_manifest_fallback.test.ts index 1292af581..f7737a2be 100644 --- a/editors/vscode/test/suite/distribution_manifest_fallback.test.ts +++ b/editors/vscode/test/suite/distribution_manifest_fallback.test.ts @@ -1,4 +1,9 @@ import * as assert from 'assert'; +import * as crypto from 'crypto'; +import { EventEmitter } from 'events'; +import { ClientRequest, IncomingMessage } from 'http'; +import https = require('https'); +import { PassThrough } from 'stream'; import { DistributionDescriptor, resolveDistributionRequest @@ -42,7 +47,121 @@ function notFound(url: string, redirected: boolean): ManifestFetchError { return new ManifestFetchError(`GET ${url} failed with HTTP 404.`, { statusCode: 404, redirected }); } +function producerManifest(overrides: Record = {}): Buffer { + const manifest = { + schema_version: '2', + product_version: '0.11.0', + distribution_generation: 'a'.repeat(64), + source_repository: 'EffortlessMetrics/ripr', + target_set: { + targets: ['x86_64-unknown-linux-gnu'], + digest: 'b'.repeat(64) + }, + producer: { tool: 'xtask release-server-manifest', schema: 'server-manifest/2' }, + build_identity: { + repository: 'EffortlessMetrics/ripr', + candidate_sha: 'c'.repeat(40), + candidate_tree: 'd'.repeat(40), + toolchain: '1.95.0', + toolchain_file_sha256: 'e'.repeat(64), + cargo_lock_sha256: 'f'.repeat(64), + profile: 'release', + features: '', + locked: true + }, + assets: { + 'x86_64-unknown-linux-gnu': { + subject: 'ripr-server-v0.11.0-x86_64-unknown-linux-gnu.tar.gz', + archive_format: 'tar.gz', + archive_size: 1234, + sha256: '1'.repeat(64), + executable: { path: 'ripr', size: 56, sha256: '2'.repeat(64) }, + receipt: { + path: 'ripr-server-v0.11.0-x86_64-unknown-linux-gnu.receipt.json', + sha256: '3'.repeat(64), + schema_version: '0.2', + target: 'x86_64-unknown-linux-gnu' + } + } + }, + ...overrides + }; + return Buffer.from(`${JSON.stringify(manifest, null, 2)}\n`, 'utf8'); +} + +async function withManifestResponses( + responses: Array<{ status: number; body: Buffer }>, + run: (requested: string[]) => Promise +): Promise { + const original = https.get; + const requested: string[] = []; + https.get = ((url: string, callback: (response: IncomingMessage) => void) => { + requested.push(url); + const selected = responses[requested.length - 1]; + assert.ok(selected, `unexpected request ${url}`); + const request = new EventEmitter() as ClientRequest; + request.setTimeout = () => request; + request.destroy = (error?: Error) => { + if (error) { request.emit('error', error); } + return request; + }; + process.nextTick(() => { + const stream = new PassThrough(); + const response = stream as unknown as IncomingMessage; + response.statusCode = selected.status; + response.headers = {}; + callback(response); + stream.end(selected.body); + }); + return request; + }) as typeof https.get; + try { + await run(requested); + } finally { + https.get = original; + } +} + suite('Distribution manifest fallback', () => { + test('real admitted RC bytes pass and changed bytes fail against the same catalog digest', async () => { + const bytes = producerManifest(); + const digest = crypto.createHash('sha256').update(bytes).digest('hex'); + const distribution = resolveDistributionRequest('0.11.0', { + ...catalog, + schema: 2, + distributionGeneration: 'a'.repeat(64), + manifestSha256: digest, + targetSetDigest: 'b'.repeat(64) + }); + await withManifestResponses([ + { status: 404, body: Buffer.alloc(0) }, + { status: 200, body: bytes } + ], async (requested) => { + // No admitted-fetcher injection: run selection, HTTP status handling, + // raw-byte digest admission and typed parsing through the default path. + const admitted = await fetchAdmittedManifestForDistribution('', distribution, '0.11.0', digest); + assert.strictEqual(admitted.manifest.productVersion, '0.11.0'); + assert.strictEqual(admitted.manifest.assets['x86_64-unknown-linux-gnu'].sha256, '1'.repeat(64)); + assert.strictEqual(admitted.manifestSelection, 'fallback_exact_after_preferred_absent'); + assert.deepStrictEqual(requested, [ + 'https://github.com/EffortlessMetrics/ripr/releases/download/v0.11.0/ripr-server-manifest-v0.11.0.json', + 'https://github.com/EffortlessMetrics/ripr/releases/download/v0.11.0-rc.1/ripr-server-manifest-v0.11.0.json' + ]); + }); + // Valid JSON with different bytes isolates the digest oracle from parsing. + const changed = Buffer.concat([bytes, Buffer.from(' ')]); + await withManifestResponses([ + { status: 404, body: Buffer.alloc(0) }, + { status: 200, body: changed } + ], async (requested) => { + await assert.rejects( + fetchAdmittedManifestForDistribution('', distribution, '0.11.0', digest), + /digest/i + ); + assert.strictEqual(requested.length, 2); + }); + }); + test('falls back to the RC placement on a direct 404 of the preferred manifest', async () => { const distribution = resolveDistributionRequest('0.11.0', catalog); const requested: string[] = []; From affb7894302e96a64aa5eedd87e36280485dbd93 Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Fri, 2 Oct 2026 22:14:23 -0400 Subject: [PATCH 12/18] test(vscode): preserve producer identity after source catalog integration --- .../vscode/test/suite/distribution_manifest_fallback.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/editors/vscode/test/suite/distribution_manifest_fallback.test.ts b/editors/vscode/test/suite/distribution_manifest_fallback.test.ts index f7737a2be..8721b0318 100644 --- a/editors/vscode/test/suite/distribution_manifest_fallback.test.ts +++ b/editors/vscode/test/suite/distribution_manifest_fallback.test.ts @@ -129,6 +129,7 @@ suite('Distribution manifest fallback', () => { const distribution = resolveDistributionRequest('0.11.0', { ...catalog, schema: 2, + producer: { tool: 'xtask release-distribution-catalog', schema: 'distribution-catalog/1' }, distributionGeneration: 'a'.repeat(64), manifestSha256: digest, targetSetDigest: 'b'.repeat(64) @@ -184,6 +185,7 @@ suite('Distribution manifest fallback', () => { const distribution = resolveDistributionRequest('0.11.0', { ...catalog, schema: 2, + producer: { tool: 'xtask release-distribution-catalog', schema: 'distribution-catalog/1' }, distributionGeneration: 'a'.repeat(64), manifestSha256: 'b'.repeat(64), targetSetDigest: 'c'.repeat(64) @@ -229,6 +231,7 @@ suite('Distribution manifest fallback', () => { const distribution = resolveDistributionRequest('0.11.0', { ...catalog, schema: 2, + producer: { tool: 'xtask release-distribution-catalog', schema: 'distribution-catalog/1' }, distributionGeneration: 'a'.repeat(64), manifestSha256: 'b'.repeat(64), targetSetDigest: 'c'.repeat(64) @@ -265,6 +268,7 @@ suite('Distribution manifest fallback', () => { const distribution = resolveDistributionRequest('0.11.0', { ...catalog, schema: 2, + producer: { tool: 'xtask release-distribution-catalog', schema: 'distribution-catalog/1' }, distributionGeneration: 'a'.repeat(64), manifestSha256: 'b'.repeat(64), targetSetDigest: 'c'.repeat(64) From 1cee021b7085bcad8cc5590eff4c7fd5d3550bf7 Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Fri, 2 Oct 2026 23:38:39 -0400 Subject: [PATCH 13/18] ci(vscode): qualify selected editor candidates without duplicate Rust gates --- .github/workflows/ci.yml | 2 +- .github/workflows/routed-rust.yml | 20 +++++++++++++++--- docs/CI.md | 18 ++++++++++++++-- xtask/src/main.rs | 35 ++++++++++++++++++++++++++++++- xtask/src/tests.rs | 32 ++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a52b7d8f..b13bb2383 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -373,7 +373,7 @@ jobs: - run: cargo check --workspace --all-targets vscode: - if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci') + if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci') || contains(github.event.pull_request.labels.*.name, 'vscode') runs-on: ubuntu-latest timeout-minutes: 30 defaults: diff --git a/.github/workflows/routed-rust.yml b/.github/workflows/routed-rust.yml index 6f71e0e06..7b967d2ee 100644 --- a/.github/workflows/routed-rust.yml +++ b/.github/workflows/routed-rust.yml @@ -26,7 +26,7 @@ permissions: # Cancelling on `synchronize` would destroy a nearly finished proof every time a # branch is pushed, which is the opposite of the repository's CI economics rule. concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}${{ github.event_name == 'pull_request' && (github.event.action == 'unlabeled' || (github.event.action == 'labeled' && github.event.label.name != 'full-ci')) && '-label-ignore' || '' }} cancel-in-progress: false env: @@ -34,6 +34,8 @@ env: jobs: route: + # Unrelated label events cannot launch proof or replace pending proof. + if: github.event_name != 'pull_request' || contains(fromJSON('["opened", "synchronize", "reopened"]'), github.event.action) || (github.event.action == 'labeled' && github.event.label.name == 'full-ci') name: Route Ripr Rust Small runs-on: ubuntu-latest timeout-minutes: 10 @@ -119,6 +121,7 @@ jobs: } >> "$GITHUB_STEP_SUMMARY" detect-docs-only: + if: github.event_name != 'pull_request' || contains(fromJSON('["opened", "synchronize", "reopened"]'), github.event.action) || (github.event.action == 'labeled' && github.event.label.name == 'full-ci') name: Detect Docs-Only Surface runs-on: ubuntu-latest timeout-minutes: 10 @@ -553,9 +556,10 @@ jobs: retention-days: 5 result: - name: Ripr Rust Small Result + # Even a skipped job must never use the required context on ignored events. + name: ${{ github.event_name == 'pull_request' && (github.event.action == 'unlabeled' || (github.event.action == 'labeled' && github.event.label.name != 'full-ci')) && 'Ripr Rust Small Ignored Label Event' || 'Ripr Rust Small Result' }} needs: [route, detect-docs-only, rust-github, docs-gate] - if: always() + if: always() && (github.event_name != 'pull_request' || contains(fromJSON('["opened", "synchronize", "reopened"]'), github.event.action) || (github.event.action == 'labeled' && github.event.label.name == 'full-ci')) runs-on: ubuntu-latest timeout-minutes: 20 steps: @@ -716,3 +720,13 @@ jobs: name: ripr-routed-rust-result-${{ github.run_id }}-${{ github.run_attempt }} path: target/ripr/reports/routed-rust-result.json if-no-files-found: error + + ignored-label: + name: Summarize Ignored Rust Label Event + if: github.event_name == 'pull_request' && (github.event.action == 'unlabeled' || (github.event.action == 'labeled' && github.event.label.name != 'full-ci')) + runs-on: ubuntu-latest + timeout-minutes: 2 + steps: + - name: Retain the non-proof disposition + run: | + echo "Unrelated label event: no Rust proof started; required result not posted." >> "$GITHUB_STEP_SUMMARY" diff --git a/docs/CI.md b/docs/CI.md index cfffe36a0..1d6db72bd 100644 --- a/docs/CI.md +++ b/docs/CI.md @@ -269,7 +269,7 @@ implement and validate the lane-selection logic. | --- | --- | | `full-ci` | Run required, advisory, and release-like lanes. Demotes `ripr-waive` for this PR. Expected to cost more. | | `release-check` | Run the currently wired release-surface proof without opting into every `full-ci` lane: package list, publish dry-run, and release-readiness. | -| `vscode` | Run editor extension lanes even when no editor path changed. | +| `vscode` | Run the existing hosted editor compile, admitted VSIX package, and editor-host test job without opting into the other `full-ci` jobs. | | `coverage` | Run coverage lanes and upload coverage artifacts. | | `ripr-waive` | Acknowledge a soft static exposure finding for this PR. Does not skip CI and does not apply when `full-ci` is present. | | `ci-budget-ack` | Acknowledge that this PR intentionally exceeds the expected LEM band. | @@ -281,7 +281,7 @@ budget/risk-pack policy files in the same PR. These labels are the documented target vocabulary. Today, `release-check` and `full-ci` activate the Rust workflow's package list, publish dry-run, and -release-readiness steps on pull requests. Other label effects remain target vocabulary until a later PR +release-readiness steps on pull requests. `vscode` now activates only the CI editor job. Other label effects remain target vocabulary until a later PR wires them into a PR plan or workflow condition. The GitHub Settings App contract in `.github/settings.yml` codifies these label names, descriptions, and colors so the reviewable vocabulary does not drift in the GitHub UI. @@ -2516,3 +2516,17 @@ A branch is ready to merge when: Local `--allow-dirty` packaging checks are useful during review but are not a substitute for plain package and publish dry-run checks on the final committed branch. + +### Scoped source editor qualification + +Use the existing `vscode` label for a selected source editor candidate. The +`ci.yml` editor job runs its existing compile, admitted-package and editor-host +commands. Rust, MSRV and release-check conditions are unchanged; the label is +not an integrated release qualification or publication decision. + +In Routed Rust, opened/synchronize/reopened, `full-ci` label additions, pushes +and manual dispatches retain the existing typed receipt/aggregate path. Other +label additions and removals use a separate concurrency group, skip proof +selection, and never post `Ripr Rust Small Result`, including as a skipped job. +Their cheap ignored-event summary proves no Rust subject. Existing proof for an +exact head remains its own evidence and cannot be replaced by a label event. diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 37619124b..3ba93ab01 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -7680,6 +7680,9 @@ fn routed_rust_workflow_contract_violations( routed_rust_workflow_contract_violations_with_reusable(workflow, None, settings, lane_whitelist) } +const SOURCE_RUST_EVENT_GUARD: &str = r#"github.event_name != 'pull_request' || contains(fromJSON('["opened", "synchronize", "reopened"]'), github.event.action) || (github.event.action == 'labeled' && github.event.label.name == 'full-ci')"#; +const SOURCE_RUST_IGNORED_EVENT: &str = "github.event_name == 'pull_request' && (github.event.action == 'unlabeled' || (github.event.action == 'labeled' && github.event.label.name != 'full-ci'))"; + fn routed_rust_workflow_contract_violations_with_reusable( workflow: &str, _reusable_workflow: Option<&str>, @@ -7688,6 +7691,36 @@ fn routed_rust_workflow_contract_violations_with_reusable( ) -> Vec { let mut violations = Vec::new(); + for job in ["route", "detect-docs-only"] { + if !routed_rust_job_block_any(workflow, job, |line| { + line.trim() == format!("if: {SOURCE_RUST_EVENT_GUARD}") + }) { + violations.push(format!( + "source routed Rust job `{job}` lacks the exact proof-event guard" + )); + } + } + if !routed_rust_job_block_any(workflow, "result", |line| { + line.trim() == format!("if: always() && ({SOURCE_RUST_EVENT_GUARD})") + }) { + violations.push("source routed Rust result lacks the exact proof-event guard".to_string()); + } + let result_name = format!( + "name: ${{{{ {SOURCE_RUST_IGNORED_EVENT} && 'Ripr Rust Small Ignored Label Event' || 'Ripr Rust Small Result' }}}}" + ); + if !routed_rust_job_block_any(workflow, "result", |line| line.trim() == result_name) { + violations.push( + "source ignored label event must not occupy the required result name".to_string(), + ); + } + let isolation = format!("${{{{ {SOURCE_RUST_IGNORED_EVENT} && '-label-ignore' || '' }}}}"); + if !workflow + .lines() + .any(|line| line.trim_start().starts_with("group:") && line.ends_with(&isolation)) + { + violations.push("source ignored label event lacks concurrency isolation".to_string()); + } + // ripr#1446: the source repository proves its own pull requests on // GitHub-hosted runners. Self-hosted capacity is `ripr-swarm` authority. This // contract previously *required* org runner discovery and three self-hosted @@ -7707,7 +7740,7 @@ fn routed_rust_workflow_contract_violations_with_reusable( "org runner query negative assertion", "org_runner_query_attempted=false", ), - ("normalized result job", "name: Ripr Rust Small Result"), + ("normalized result job", "Ripr Rust Small Result"), ( "hosted rust route predicate", "needs.route.outputs.route == 'github_hosted_rust'", diff --git a/xtask/src/tests.rs b/xtask/src/tests.rs index aa407c8be..68da4aac1 100644 --- a/xtask/src/tests.rs +++ b/xtask/src/tests.rs @@ -10825,6 +10825,38 @@ fn routed_rust_workflow_contract_rejects_missing_receipt_or_route_assertion() -> Ok(()) } +#[test] +fn source_routed_rust_ignored_labels_cannot_replace_proof() -> Result<(), String> { + let workflow = routed_rust_workflow_text()?; + for (snippet, expected) in [ + ( + "if: github.event_name != 'pull_request' || contains(fromJSON", + "proof-event guard", + ), + ("'-label-ignore'", "concurrency isolation"), + ( + "'Ripr Rust Small Ignored Label Event'", + "required result name", + ), + ( + "if: always() && (github.event_name != 'pull_request'", + "proof-event guard", + ), + ] { + let mutated = workflow.replacen(snippet, "REMOVED_CONTROL", 1); + let violations = routed_rust_workflow_contract_violations(&mutated, None, None); + if !violations + .iter() + .any(|violation| violation.contains(expected)) + { + return Err(format!( + "removal of {snippet} was not rejected: {violations:?}" + )); + } + } + Ok(()) +} + #[test] fn routed_rust_workflow_contract_rejects_self_hosted_reintroduction() { // ripr#1446: self-hosted runner authority belongs to ripr-swarm. The source From c56a816f28c47ad23806d8764e2afd1ccae00673 Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Sat, 3 Oct 2026 00:09:31 -0400 Subject: [PATCH 14/18] policy(vscode): bind deterministic manifest transport mock references --- policy/network_allowlist.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/policy/network_allowlist.txt b/policy/network_allowlist.txt index e7e9a5b29..62b718003 100644 --- a/policy/network_allowlist.txt +++ b/policy/network_allowlist.txt @@ -26,6 +26,7 @@ crates/ripr/src/output/perl_gap_record_projection.rs|curl|5|analysis-perl|Absenc crates/ripr/src/output/pr_inline_comment_publish_plan.rs|"push"|1|output/pr-inline-plan|A unit fixture names the GitHub push event to prove inline publication is blocked for an unsafe event; it performs no network operation. crates/ripr/src/output/typescript_packet_projection.rs|curl|4|analysis-typescript|F7 absence-assertions: comments + unit tests verifying the TS receipt_command is a fixed `ripr outcome` shape that never invokes curl/an external provider. No network behavior; these reference the term only to prove it is absent. editors/vscode/src/downloader.ts|https.get|1|lsp/editor|VS Code extension downloads verified server assets from the configured release source. +editors/vscode/test/suite/distribution_manifest_fallback.test.ts|https.get|4|lsp/editor-tests|Deterministic HTTPS response mock exercises default manifest admission; restores original in finally and performs no real network requests. xtask/src/branch_inventory.rs|"push"|2|repo-ops/branch-inventory|Owner-confirmed stale-branch deletion constructs one force-with-lease Git push command and its exact unit-test expectation. xtask/src/main.rs|"push"|1|xtask/test-efficiency|The test-efficiency analyzer ignores the common Vec push method when classifying meaningful test calls; this token does not invoke Git or network access. xtask/src/reports/source_promotion_admission_fixture.rs|curl|8|release/source-promotion-admission|RIPR-SPEC-0177: the deterministic J5 fixture retains exact governed curl-token cardinality across synthetic source-only policy rows and tests; it executes the production checker locally and performs no network request. From 0f5392c003ff62654a1054d364b30877b3292a7b Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Sat, 3 Oct 2026 00:54:39 -0400 Subject: [PATCH 15/18] fix(ci): bind routed proof controls to their YAML scopes --- xtask/src/main.rs | 29 ++++++++++++---- xtask/src/tests.rs | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 6 deletions(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 3ba93ab01..69f6c02bf 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -7645,20 +7645,40 @@ fn routed_rust_job_block_any( mut predicate: impl FnMut(&str) -> bool, ) -> bool { let job_header = format!("{job}:"); + let mut in_jobs = false; let mut in_block = false; for line in workflow.lines() { + if !line.is_empty() && !line.starts_with(' ') && !line.starts_with('#') { + in_jobs = line.trim() == "jobs:"; + in_block = false; + continue; + } let job_level_key = line.starts_with(" ") && !line.starts_with(" ") && line.trim_end().ends_with(':') && !line.trim_start().starts_with('-'); if job_level_key { - in_block = line.trim() == job_header; + in_block = in_jobs && line.trim() == job_header; continue; } if in_block && !line.is_empty() && !line.starts_with(' ') { break; } - if in_block && predicate(line) { + if in_block && line.starts_with(" ") && !line.starts_with(" ") && predicate(line) { + return true; + } + } + false +} + +fn routed_rust_concurrency_group_has_isolation(workflow: &str, isolation: &str) -> bool { + let mut in_concurrency = false; + for line in workflow.lines() { + if !line.is_empty() && !line.starts_with(' ') && !line.starts_with('#') { + in_concurrency = line.trim() == "concurrency:"; + continue; + } + if in_concurrency && line.starts_with(" group:") && line.ends_with(isolation) { return true; } } @@ -7714,10 +7734,7 @@ fn routed_rust_workflow_contract_violations_with_reusable( ); } let isolation = format!("${{{{ {SOURCE_RUST_IGNORED_EVENT} && '-label-ignore' || '' }}}}"); - if !workflow - .lines() - .any(|line| line.trim_start().starts_with("group:") && line.ends_with(&isolation)) - { + if !routed_rust_concurrency_group_has_isolation(workflow, &isolation) { violations.push("source ignored label event lacks concurrency isolation".to_string()); } diff --git a/xtask/src/tests.rs b/xtask/src/tests.rs index 68da4aac1..3e6895def 100644 --- a/xtask/src/tests.rs +++ b/xtask/src/tests.rs @@ -10857,6 +10857,93 @@ fn source_routed_rust_ignored_labels_cannot_replace_proof() -> Result<(), String Ok(()) } +#[test] +fn source_routed_rust_controls_reject_wrong_yaml_scope() -> Result<(), String> { + let workflow = routed_rust_workflow_text()?.replace("\r\n", "\n"); + for (job, key, expected) in [ + ("route", "if:", "proof-event guard"), + ("detect-docs-only", "if:", "proof-event guard"), + ("result", "if:", "proof-event guard"), + ("result", "name:", "required result name"), + ] { + let start = workflow.find(&format!("\n {job}:\n")).unwrap(); + let rest = &workflow[start + 1..]; + let mut end = rest.len(); + let mut offset = 0; + for line in rest.split_inclusive('\n') { + if offset > 0 && line.starts_with(" ") && !line.starts_with(" ") { + end = offset; + break; + } + offset += line.len(); + } + let block = &rest[..end]; + let control = block + .lines() + .find(|line| line.starts_with(&format!(" {key}"))) + .unwrap(); + let step = if key == "name:" { + format!( + " - id: scope_control\n {}\n run: echo scope-control\n", + control.trim() + ) + } else { + format!( + " - name: Scope control\n {}\n run: echo scope-control\n", + control.trim() + ) + }; + let relocated = block.replacen(&format!("{control}\n"), "", 1).replacen( + " steps:\n", + &format!(" steps:\n{step}"), + 1, + ); + let mutated = workflow.replacen(block, &relocated, 1); + assert_ne!(mutated, workflow); + assert!( + routed_rust_workflow_contract_violations(&mutated, None, None) + .iter() + .any(|violation| violation.contains(expected)), + "relocated {job}.{key} must be rejected" + ); + } + let group = workflow + .lines() + .find(|line| line.starts_with(" group:")) + .unwrap(); + let without_group = workflow.replacen(&format!("{group}\n"), "", 1); + for relocated in [ + without_group.replacen("env:\n", &format!("env:\n{group}\n"), 1), + without_group.replacen(" steps:\n", &format!(" steps:\n - name: Scope control\n env:\n {group}\n run: echo scope-control\n"), 1), + ] { + assert!( + routed_rust_workflow_contract_violations(&relocated, None, None) + .iter() + .any(|violation| violation.contains("concurrency isolation")), + "group outside workflow concurrency must be rejected" + ); + } + let scoped = "jobs:\n route:\n\n # direct mapping key\n if: exact\n steps:\n - run: echo test\nenv:\n route:\n if: wrong\n"; + assert!(routed_rust_job_block_any(scoped, "route", |line| line + .trim() + == "if: exact")); + assert!(!routed_rust_job_block_any(scoped, "route", |line| line + .trim() + == "if: wrong")); + for unsupported in [ + "jobs:\n route:\n if: exact\n", + "jobs:\n route:\n if: >-\n exact\n", + "env:\n route:\n if: exact\n", + ] { + assert!(!routed_rust_job_block_any( + unsupported, + "route", + |line| line.trim() == "if: exact" + )); + } + Ok(()) +} + #[test] fn routed_rust_workflow_contract_rejects_self_hosted_reintroduction() { // ripr#1446: self-hosted runner authority belongs to ripr-swarm. The source From 63e606201433fae32ee1249c98ddf78de1053112 Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Sat, 3 Oct 2026 01:01:25 -0400 Subject: [PATCH 16/18] fix(test): qualify routed workflow helper from child module --- xtask/src/tests.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/xtask/src/tests.rs b/xtask/src/tests.rs index 3e6895def..48205541a 100644 --- a/xtask/src/tests.rs +++ b/xtask/src/tests.rs @@ -10924,18 +10924,22 @@ fn source_routed_rust_controls_reject_wrong_yaml_scope() -> Result<(), String> { ); } let scoped = "jobs:\n route:\n\n # direct mapping key\n if: exact\n steps:\n - run: echo test\nenv:\n route:\n if: wrong\n"; - assert!(routed_rust_job_block_any(scoped, "route", |line| line - .trim() - == "if: exact")); - assert!(!routed_rust_job_block_any(scoped, "route", |line| line - .trim() - == "if: wrong")); + assert!(crate::routed_rust_job_block_any( + scoped, + "route", + |line| line.trim() == "if: exact" + )); + assert!(!crate::routed_rust_job_block_any( + scoped, + "route", + |line| line.trim() == "if: wrong" + )); for unsupported in [ "jobs:\n route:\n if: exact\n", "jobs:\n route:\n if: >-\n exact\n", "env:\n route:\n if: exact\n", ] { - assert!(!routed_rust_job_block_any( + assert!(!crate::routed_rust_job_block_any( unsupported, "route", |line| line.trim() == "if: exact" From d5d04a906cd9327e4ec56a24e55c2cb38d5bad7a Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Sat, 3 Oct 2026 01:29:57 -0400 Subject: [PATCH 17/18] fix(test): propagate workflow fixture lookup errors --- xtask/src/tests.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xtask/src/tests.rs b/xtask/src/tests.rs index 48205541a..be315369a 100644 --- a/xtask/src/tests.rs +++ b/xtask/src/tests.rs @@ -10866,7 +10866,9 @@ fn source_routed_rust_controls_reject_wrong_yaml_scope() -> Result<(), String> { ("result", "if:", "proof-event guard"), ("result", "name:", "required result name"), ] { - let start = workflow.find(&format!("\n {job}:\n")).unwrap(); + let start = workflow + .find(&format!("\n {job}:\n")) + .ok_or("canonical workflow lacks the selected job")?; let rest = &workflow[start + 1..]; let mut end = rest.len(); let mut offset = 0; @@ -10881,7 +10883,7 @@ fn source_routed_rust_controls_reject_wrong_yaml_scope() -> Result<(), String> { let control = block .lines() .find(|line| line.starts_with(&format!(" {key}"))) - .unwrap(); + .ok_or("canonical workflow lacks the selected direct control")?; let step = if key == "name:" { format!( " - id: scope_control\n {}\n run: echo scope-control\n", @@ -10910,7 +10912,7 @@ fn source_routed_rust_controls_reject_wrong_yaml_scope() -> Result<(), String> { let group = workflow .lines() .find(|line| line.starts_with(" group:")) - .unwrap(); + .ok_or("canonical workflow lacks its concurrency group")?; let without_group = workflow.replacen(&format!("{group}\n"), "", 1); for relocated in [ without_group.replacen("env:\n", &format!("env:\n{group}\n"), 1), From 5c761012460abb4aaa4634a4666d48bfe1bfe77f Mon Sep 17 00:00:00 2001 From: "Steven Zimmerman, CPA" <15812269+EffortlessSteven@users.noreply.github.com> Date: Sat, 3 Oct 2026 01:49:59 -0400 Subject: [PATCH 18/18] fix(ci): exclude YAML comments from concurrency isolation proof --- xtask/src/main.rs | 20 ++++++++++++++++++-- xtask/src/tests.rs | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 69f6c02bf..3acc291ae 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -7678,8 +7678,24 @@ fn routed_rust_concurrency_group_has_isolation(workflow: &str, isolation: &str) in_concurrency = line.trim() == "concurrency:"; continue; } - if in_concurrency && line.starts_with(" group:") && line.ends_with(isolation) { - return true; + if in_concurrency && let Some(value) = line.strip_prefix(" group: ") { + let value = value.trim_start(); + // Only the workflow's plain scalar style is supported. Text in + // a YAML comment must never satisfy the isolation contract. + if value.starts_with(['\'', '"', '|', '>']) { + return false; + } + let comment = value.char_indices().find_map(|(index, character)| { + (character == '#' + && (index == 0 + || value[..index] + .chars() + .next_back() + .is_some_and(char::is_whitespace))) + .then_some(index) + }); + let value = &value[..comment.unwrap_or(value.len())]; + return value.trim_end().ends_with(isolation); } } false diff --git a/xtask/src/tests.rs b/xtask/src/tests.rs index be315369a..7af4f338a 100644 --- a/xtask/src/tests.rs +++ b/xtask/src/tests.rs @@ -10918,6 +10918,7 @@ fn source_routed_rust_controls_reject_wrong_yaml_scope() -> Result<(), String> { without_group.replacen("env:\n", &format!("env:\n{group}\n"), 1), without_group.replacen(" steps:\n", &format!(" steps:\n - name: Scope control\n env:\n {group}\n run: echo scope-control\n"), 1), ] { + assert_ne!(relocated, workflow); assert!( routed_rust_workflow_contract_violations(&relocated, None, None) .iter() @@ -10947,6 +10948,41 @@ fn source_routed_rust_controls_reject_wrong_yaml_scope() -> Result<(), String> { |line| line.trim() == "if: exact" )); } + let isolation = format!( + "${{{{ {} && '-label-ignore' || '' }}}}", + crate::SOURCE_RUST_IGNORED_EVENT + ); + for value in [ + format!("shared # {isolation}"), + format!("shared\t# {isolation}"), + format!("\"shared{isolation}\""), + format!("'shared{isolation}'"), + format!(">-\n shared{isolation}"), + ] { + let mutated = workflow.replacen(group, &format!(" group: {value}"), 1); + assert_ne!(mutated, workflow); + assert!( + !crate::routed_rust_concurrency_group_has_isolation(&mutated, &isolation), + "inline comment or unsupported scalar must not establish isolation" + ); + assert!( + routed_rust_workflow_contract_violations(&mutated, None, None) + .iter() + .any(|violation| violation.contains("concurrency isolation")) + ); + } + for comment in [" # retained explanation", "\t# retained explanation"] { + let annotated = workflow.replacen(group, &format!("{group}{comment}"), 1); + assert_ne!(annotated, workflow); + assert!( + crate::routed_rust_concurrency_group_has_isolation(&annotated, &isolation), + "a real plain group value retains isolation before a trailing comment" + ); + assert_eq!( + routed_rust_workflow_contract_violations(&annotated, None, None).len(), + 0 + ); + } Ok(()) }