Review planner sorts Swift and Xcode files by risk instead of sending every iOS PR to the full panel (GST-3041) (#4469)

/ship's review planner now sorts Swift and Xcode files by risk, so a
plain iOS UI change gets the light review instead of the full
five-reader panel.

Why: `gstack-diff-scope` had no rule for `.swift`, so every all-Swift
diff printed `SCOPE_ERROR=unmatched` and the planner failed closed.
Reported from the GHome iOS app's PR review.

Nothing to do: unknown file types still fail closed exactly as before.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/outside-voice#1 reader=outside-voice
Review-Finding: p2/red-team#1 reader=red-team
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-18 01:28:22 +00:00
1 parent cbd21f9424
commit 29e950227b
14 files changed
+140 -7

No files matched your search

+48
View File
@@ -161,6 +161,19 @@ describe('gstack-diff-scope', () => {
expect(runScope(createRepo(['packages/cache/pubspec.lock'])).SCOPE_CONFIG).toBe('true');
});
// Value: protects=an iOS UI change plans its review instead of failing closed; fails_when=.swift matches no arm and the
// diff prints SCOPE_ERROR=unmatched (review-depth then forces the full panel); why_new=GST-3041: ghome#32, a 55-line
// SwiftUI copy change, got 5 readers and a coverage audit; seam=none; no_claim=which readers that plan dispatches
test('a ghome#32-like SwiftUI change is frontend and backend, not unmatched (GST-3041)', () => {
const { vars, status, stdout } = runScopeFull(createRepo([
'App/AppModel.swift', 'App/Watch/PhoneWatchLink.swift', 'App/Review/ReviewView.swift', 'App/Health/HealthSync.swift',
'App/Home/SettingsView.swift', 'App/Meeting/InSessionView.swift', 'App/Meeting/MeetingRecorder.swift', 'App/Brief/YourDayViews.swift',
]));
expect(stdout).not.toContain('SCOPE_ERROR');
expect(status).toBe(0);
expect(vars).toMatchObject({ SCOPE_FRONTEND: 'true', SCOPE_BACKEND: 'true', SCOPE_AUTH: 'false', SCOPE_CONFIG: 'false', SCOPE_API: 'false' });
});
test('detects test files', () => {
const dir = createRepo(['test/app.test.ts']);
const scope = runScope(dir);
@@ -342,6 +355,32 @@ describe('glob classes (table-driven, #2526 + #2455)', () => {
{ name: 'contest_rules.py is not a test', file: 'pkg/contest_rules.py', expects: ['SCOPE_BACKEND'], alsoFalse: ['SCOPE_TESTS'] },
{ name: 'testing/ dir is not a test dir', file: 'pkg/testing/fixtures_loader.py', expects: ['SCOPE_BACKEND'], alsoFalse: ['SCOPE_TESTS'] },
{ name: 'attest_*.py is not a test', file: 'pkg/attest_signer.py', expects: ['SCOPE_BACKEND'], alsoFalse: ['SCOPE_TESTS'] },
// Swift and Xcode (GST-3041). Source, Interface Builder files, string catalogs and asset catalogs read as UI and app
// code, the way .dart and .tsx do. Files that carry real risk never read as UI: permissions (Info.plist, entitlements,
// the privacy manifest) are AUTH like any *permission* path; dependency manifests and locks, the project file and build
// settings are CONFIG like package.json and Gemfile.lock; Swift under an auth or api path keeps AUTH or API.
{ name: 'SwiftUI view', file: 'App/Review/ReviewView.swift', expects: ['SCOPE_FRONTEND', 'SCOPE_BACKEND'], alsoFalse: ['SCOPE_AUTH', 'SCOPE_CONFIG'] },
{ name: 'storyboard', file: 'App/Base.lproj/Main.storyboard', expects: ['SCOPE_FRONTEND'], alsoFalse: ['SCOPE_BACKEND', 'SCOPE_AUTH'] },
{ name: 'xib', file: 'App/Cells/ItemCell.xib', expects: ['SCOPE_FRONTEND'], alsoFalse: ['SCOPE_BACKEND'] },
{ name: 'legacy .strings', file: 'App/en.lproj/Localizable.strings', expects: ['SCOPE_FRONTEND'], alsoFalse: ['SCOPE_BACKEND'] },
{ name: '.stringsdict plurals', file: 'App/en.lproj/Localizable.stringsdict', expects: ['SCOPE_FRONTEND'], alsoFalse: ['SCOPE_BACKEND'] },
{ name: 'string catalog', file: 'App/Localizable.xcstrings', expects: ['SCOPE_FRONTEND'], alsoFalse: ['SCOPE_BACKEND'] },
{ name: 'asset catalog', file: 'App/Assets.xcassets/AccentColor.colorset/Contents.json', expects: ['SCOPE_FRONTEND'], alsoFalse: ['SCOPE_BACKEND'] },
{ name: 'Info.plist is permissions (URL schemes, ATS, usage strings)', file: 'App/Info.plist', expects: ['SCOPE_AUTH', 'SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND'] },
{ name: 'GoogleService-Info.plist reads as Info.plist', file: 'App/GoogleService-Info.plist', expects: ['SCOPE_AUTH', 'SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND'] },
{ name: 'entitlements are permissions', file: 'App/GHome.entitlements', expects: ['SCOPE_AUTH', 'SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND'] },
{ name: 'privacy manifest is permissions', file: 'App/PrivacyInfo.xcprivacy', expects: ['SCOPE_AUTH', 'SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND'] },
{ name: 'other plist is config', file: 'App/Defaults.plist', expects: ['SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND', 'SCOPE_AUTH'] },
{ name: 'Package.swift is a dependency manifest, never UI', file: 'Package.swift', expects: ['SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND', 'SCOPE_BACKEND'] },
{ name: 'nested Package.swift', file: 'Packages/GHomeCore/Package.swift', expects: ['SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND', 'SCOPE_BACKEND'] },
{ name: 'Package.resolved in the project', file: 'GHome.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved', expects: ['SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND'] },
{ name: 'Podfile', file: 'Podfile', expects: ['SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND'] },
{ name: 'Podfile.lock', file: 'ios/Podfile.lock', expects: ['SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND'] },
{ name: 'project.pbxproj is build settings and signing', file: 'GHome.xcodeproj/project.pbxproj', expects: ['SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND', 'SCOPE_BACKEND'] },
{ name: 'xcconfig is build settings', file: 'Config/Release.xcconfig', expects: ['SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND'] },
{ name: 'shared scheme', file: 'GHome.xcodeproj/xcshareddata/xcschemes/GHome.xcscheme', expects: ['SCOPE_CONFIG'], alsoFalse: ['SCOPE_FRONTEND'] },
{ name: 'Swift under an auth path keeps AUTH', file: 'App/Auth/SignInView.swift', expects: ['SCOPE_AUTH', 'SCOPE_FRONTEND', 'SCOPE_BACKEND'] },
{ name: 'Swift under an api path keeps API', file: 'Sources/GHomeCore/api/GatewayClient.swift', expects: ['SCOPE_API', 'SCOPE_BACKEND'] },
];
for (const row of TABLE) {
@@ -391,6 +430,15 @@ describe('exit-code contract (#2526)', () => {
expect(vars.SCOPE_API).toBe('false');
});
// Value: protects=an Apple file type no arm knows still fails closed after Swift and Xcode got arms; fails_when=a broad
// *.swift-style or catch-all arm swallows unknown extensions; why_new=GST-3041 added Apple arms; seam=none; no_claim=none
test('an unknown Apple file type (a Metal shader) still fails closed (GST-3041)', () => {
const { vars, status, stdout } = runScopeFull(createRepo(['App/Shaders/Glow.metal']));
expect(status).toBe(2);
expect(vars.SCOPE_ERROR).toBe('unmatched');
expect(stdout).toContain('# unmatched: App/Shaders/Glow.metal');
});
test('unresolvable base → SCOPE_ERROR=no_base + exit 2 (a green would mean "could not look")', () => {
const dir = createRepo(['app.ts']);
const result = spawnSync('bash', [SCRIPT, 'no-such-branch'], { cwd: dir, stdio: 'pipe', timeout: 5000 });
+1 -1
View File
@@ -1 +1 @@
{"sha":"25a7de61580398df96dca3651b10b2494825047e0898980406928b931b5f90af","replay":"GST-1350"}
{"sha":"2dbe134d502279da7a5f27e5370bb45a9658f01322030b1e27180d0e9e11285d","replay":"GST-3041"}
+1
View File
@@ -0,0 +1 @@
{"replay":"GST-3041","justification":"GST-3041 no-loss replay: the review-risk.ts SECURITY_LINE alternative for Swift networking (URLSession, URLRequest, NWConnection, Alamofire) only adds security hits. Planner depth from 2081e670 (old) and a936221e (new) on the last 200 first-parent main commits (64862e41..cbd21f94): 200 identical (126 full, 74 light), 0 raised, 0 lowered, no risk class lost. Controls: a URLSession client fixture raises light to full with risk security; a SwiftUI-only fixture stays light. Reviewer text is unchanged."}
+15
View File
@@ -47,6 +47,21 @@ const SAMPLES: Array<[string, boolean]> = [
['lib/widgets/bbtm_drawer/view/bbtm_drawer.dart', true],
['packages/cache/lib/cache.dart', true],
['test/ui/drawer_widget_test.dart', true],
['App/Review/ReviewView.swift', true],
['App/Base.lproj/Main.storyboard', true],
['App/Cells/ItemCell.xib', true],
['App/en.lproj/Localizable.strings', true],
['App/en.lproj/Localizable.stringsdict', true],
['App/Localizable.xcstrings', true],
['App/Assets.xcassets/AppIcon.appiconset/Contents.json', true],
['Package.swift', false],
['Packages/GHomeCore/Package.swift', false],
['Packages/components/Package.swift', false], // the manifest arm wins over */components/*, as it does in the script
['App/Info.plist', false],
['App/GHome.entitlements', false],
['GHome.xcodeproj/project.pbxproj', false],
['Config/Release.xcconfig', false],
['App/Shaders/Glow.metal', false],
];
describe('isFrontendPath', () => {
+4
View File
@@ -911,6 +911,9 @@ describe('scan', () => {
// fails_when=the .dart exclusion in resolveTargets is dropped; why_new=no --changed case had a Dart file; seam=none;
// no_claim=the real impeccable engine (fake engine logs argv)
fs.writeFileSync(path.join(REPO, 'drawer.dart'), 'class Drawer {}\n'); // untracked Dart: frontend scope, not a scan target
// Value: protects=a SwiftUI file (frontend scope since GST-3041) never reaches the web-source engine either; fails_when=the
// native-UI exclusion covers .dart only; why_new=GST-3041 made .swift frontend; seam=none; no_claim=the real engine
fs.writeFileSync(path.join(REPO, 'ReviewView.swift'), 'struct ReviewView {}\n');
const log = path.join(SANDBOX, 'argv4.log');
fs.rmSync(log, { force: true });
try {
@@ -923,6 +926,7 @@ describe('scan', () => {
fs.rmSync(path.join(REPO, 'styles'), { recursive: true, force: true });
fs.rmSync(path.join(REPO, 'notes.md'), { force: true });
fs.rmSync(path.join(REPO, 'drawer.dart'), { force: true });
fs.rmSync(path.join(REPO, 'ReviewView.swift'), { force: true });
git(REPO, 'checkout', '-q', 'main');
git(REPO, 'branch', '-q', '-D', 'feature');
}
+17
View File
@@ -60,6 +60,23 @@ describe('gstack-review-plan', () => {
expect(r.stdout).toContain('REVIEW_PLAN: class=tests pass=1 next=full dispatches=1 numbers=no');
expect(r.stdout.split('\n').filter(l => l.startsWith('DISPATCH: '))).toEqual(['DISPATCH: specialist batched effort=medium checklists=testing']);
});
// Value: protects=an iOS UI change plans by risk instead of failing closed to the full panel, while Apple permissions still plan
// full; fails_when=gstack-diff-scope prints SCOPE_ERROR=unmatched for .swift, or Info.plist reads as plain UI; why_new=GST-3041:
// ghome#32, a 55-line SwiftUI copy change, got 5 readers and a coverage audit; seam=gstack-review-plan on a real repo;
// no_claim=what the readers find
test('a SwiftUI change plans light, not the fail-closed panel; an Info.plist edit plans gate (GST-3041)', () => {
const view = 'import SwiftUI\nstruct ReviewView: View {\n var body: some View { Text("Saved") }\n}\n';
const ui = { 'App/Review/ReviewView.swift': view, 'App/Home/SettingsView.swift': view, 'App/AppModel.swift': 'final class AppModel {}\n', 'Tests/GHomeTests/HealthSyncTests.swift': 'import XCTest\n' };
const light = run(repo(ui), []);
expect(light.stdout).not.toContain('DEPTH_ERROR');
expect(light.stdout).toMatch(/^REVIEW_DEPTH: light /m);
expect(light.stdout).toMatch(/^REVIEW_PLAN: class=code /m);
const plist = run(repo({ ...ui, 'App/Info.plist': '<plist><dict><key>NSAllowsArbitraryLoads</key><true/></dict></plist>\n' }), []);
expect(plist.stdout).toMatch(/^REVIEW_CLASS: gate .*auth paths/m);
expect(plist.stdout).toMatch(/^REVIEW_DEPTH: full /m);
const client = run(repo({ ...ui, 'App/Client.swift': 'final class Client {\n func load(_ r: URLRequest) async throws -> Data { try await URLSession.shared.data(for: r).0 }\n}\n' }), []);
expect(client.stdout).toMatch(/^REVIEW_DEPTH: full .*risk:security/m);
});
test('a docs diff that publishes numbers keeps the outside voice', () => {
const r = run(repo({ 'docs/bench.md': 'Median latency fell 42% to 180 ms.\n' }), []);
expect(r.stdout).toContain('DISPATCH: outside-voice outside-voice effort=host');
+15
View File
@@ -277,6 +277,21 @@ describe('GST-850: security reaches outbound URLs, archives, path traversal and
});
});
describe('GST-3041: Swift networking is security, SwiftUI is not', () => {
// Value: protects=a Swift diff that adds an outbound HTTP client still reaches the full panel now that .swift no longer fails closed;
// fails_when=URLSession, URLRequest, NWConnection or Alamofire reads light, or an ordinary SwiftUI view raises a class; seam=matchRisk
test.each([
'let (data, _) = try await URLSession.shared.data(for: request)', 'let session = URLSession(configuration: .ephemeral)',
'var request = URLRequest(url: endpoint)', 'let conn = NWConnection(host: host, port: 443, using: .tls)', 'import Alamofire', 'AF.request(url).responseDecodable(of: Item.self) { _ in }',
])('%s is security', line => {
expect(risk(['App/Client.swift'], { 'App/Client.swift': [line] })).toEqual(['security']);
});
test('an ordinary SwiftUI view is not security', () => {
for (const line of ['struct ReviewView: View {', ' var body: some View { Text("Saved") }', 'let url = URL(string: "https://example.com")!', '@State private var request = ""'])
expect(risk(['App/ReviewView.swift'], { 'App/ReviewView.swift': [line] })).toEqual([]);
});
});
describe('GST-850: money reaches metering, charge and credit code', () => {
// Value: protects=a billing-client or metering diff gets the money reader; fails_when=gbrain-evals #289 reads required=none again,
// or costume, a CLI usage line or a proxy with no billing names money; seam=matchRisk and targetedClasses