diff --git a/bin/gstack-design-detect.ts b/bin/gstack-design-detect.ts index b5ffd67cc..addb543fe 100755 --- a/bin/gstack-design-detect.ts +++ b/bin/gstack-design-detect.ts @@ -96,7 +96,7 @@ import { import { writeReceipt, writeOutcome } from '../lib/egress-receipt'; import { readConfigKey, resolveStateRoot } from '../lib/state-root'; import { DESIGN_SLOP_CATALOG, entryForImpeccableId } from '../lib/design-catalog'; -import { isFrontendPath } from '../lib/frontend-scope'; +import { isFrontendPath, isNativeUiPath } from '../lib/frontend-scope'; import { baseArg } from '../lib/gate-diff/git'; // ── Environment ────────────────────────────────────────────────────────────── @@ -830,8 +830,8 @@ function resolveTargets(args: ScanArgs, p: Probe): { targets: string[]; refusedB runZ(['diff', '-z', '--name-only', '--diff-filter=ACMR', 'HEAD']); runZ(['ls-files', '-z', '--others', '--exclude-standard']); for (const rel of [...files].sort()) { - // impeccable reads web sources; a Dart file is frontend scope but not a scan target. - if (!isFrontendPath(rel) || rel.endsWith('.dart')) continue; + // impeccable reads web sources; a Dart or Swift file is frontend scope but not a scan target. + if (!isFrontendPath(rel) || isNativeUiPath(rel)) continue; const abs = path.join(top, rel); try { if (fs.lstatSync(abs).isSymbolicLink()) { refuse(rel, 'symlink named by git is never scanned'); continue; } } catch { continue; } const real = realpathOrNull(abs); diff --git a/bin/gstack-diff-scope b/bin/gstack-diff-scope index 8c63dda07..3b6d8dd10 100755 --- a/bin/gstack-diff-scope +++ b/bin/gstack-diff-scope @@ -246,6 +246,8 @@ for f in ${FILES_LIST[@]+"${FILES_LIST[@]}"}; do # Frontend: CSS, views, components, templates case "$f" in + # SwiftPM's manifest is a dependency file (CONFIG below), never UI. + Package.swift|*/Package.swift) ;; *.css|*.scss|*.less|*.sass|*.pcss) m_frontend=true ;; *.tsx|*.jsx|*.vue|*.svelte|*.astro) m_frontend=true ;; *.erb|*.haml|*.slim|*.hbs|*.ejs) m_frontend=true ;; @@ -255,6 +257,11 @@ for f in ${FILES_LIST[@]+"${FILES_LIST[@]}"}; do # A skipped reviewer is invisible; an extra one (design-lite included) is a # visible pass that costs a review. *.dart) m_frontend=true ;; + # Swift, the same way (GST-3041): a SwiftUI view and a network client share + # the extension. Interface Builder files, string catalogs and asset catalogs + # are UI only. + *.swift) m_frontend=true ;; + *.storyboard|*.xib|*.strings|*.stringsdict|*.xcstrings|*.xcassets/*) m_frontend=true ;; tailwind.config.*|postcss.config.*) m_frontend=true ;; app/views/*|*/components/*|styles/*|css/*|app/assets/stylesheets/*) m_frontend=true ;; esac @@ -290,6 +297,12 @@ for f in ${FILES_LIST[@]+"${FILES_LIST[@]}"}; do .gstack/*) m_config=true ;; requirements.txt|pyproject.toml|go.mod|Cargo.toml|composer.json) m_config=true ;; pubspec.lock|*/pubspec.lock) m_config=true ;; + # Apple dependencies, project file and build settings (signing included); + # Info.plist and entitlements also read as AUTH below. + Package.swift|*/Package.swift|Package.resolved|*/Package.resolved) m_config=true ;; + Podfile|*/Podfile|Podfile.lock|*/Podfile.lock|Cartfile|*/Cartfile|Cartfile.resolved|*/Cartfile.resolved) m_config=true ;; + *.pbxproj|*.xcconfig|*.xcscheme|*.xcworkspacedata|*.xctestplan) m_config=true ;; + *.plist|*.entitlements|*.xcprivacy) m_config=true ;; esac # Migrations: database migration files. Bare migrations/* covers a @@ -316,6 +329,10 @@ for f in ${FILES_LIST[@]+"${FILES_LIST[@]}"}; do case "$f" in *jwt*|*permission*|*role*) m_auth=true ;; *session*) _session_data "$f" || m_auth=true ;; + # Apple permissions (GST-3041): Info.plist holds URL schemes, App Transport + # Security exceptions and usage strings; entitlements grant capabilities + # (keychain groups, push, HealthKit); the privacy manifest declares data use. + Info.plist|*/Info.plist|*-Info.plist|*.entitlements|*.xcprivacy) m_auth=true ;; esac _auth_path "$f" && m_auth=true @@ -330,6 +347,8 @@ for f in ${FILES_LIST[@]+"${FILES_LIST[@]}"}; do fi case "$f" in *.dart) m_backend=true ;; + Package.swift|*/Package.swift) ;; + *.swift) m_backend=true ;; esac [ "$m_frontend" = true ] && FRONTEND=true diff --git a/changelog.d/review-plan-sorts-swift-paths.md b/changelog.d/review-plan-sorts-swift-paths.md new file mode 100644 index 000000000..64a158ba7 --- /dev/null +++ b/changelog.d/review-plan-sorts-swift-paths.md @@ -0,0 +1 @@ +- **/ship's review plan now sorts Swift and Xcode files by risk instead of sending every iOS PR to the full review panel (GST-3041).** `gstack-diff-scope` had no rule for `.swift`, so an all-Swift diff printed `SCOPE_ERROR=unmatched` and the planner failed closed to five readers plus a coverage audit; a 55-line SwiftUI copy change got the whole panel. Swift source now reads as UI and app code (like Dart), as do storyboards, XIBs, string catalogs and asset catalogs. `Info.plist`, entitlements and the privacy manifest read as permissions (auth), and `Package.swift`, `Package.resolved`, `Podfile`(`.lock`), `project.pbxproj`, `.xcconfig` and schemes read as config, never as UI. Swift networking code (`URLSession`, `URLRequest`, `NWConnection`, Alamofire) still raises the review to full depth, the same as `fetch` in TypeScript. A file type no rule knows, such as a Metal shader, still fails closed. Reported from the GHome iOS app's PR review. diff --git a/docs/review-policy.md b/docs/review-policy.md index 4c1a321f8..f483e3e54 100644 --- a/docs/review-policy.md +++ b/docs/review-policy.md @@ -416,7 +416,7 @@ redaction call, an import of a redaction or outside-voice module, a `SECRET` or constant set to a regex, since that code decides what reaches an outside model, GST-1177; `shell: true`, `exec(` and `execSync(`, `eval`, `new Function(`, raw HTML sinks, a shell run through argv, recursive deletes), any call to an outbound HTTP client (`fetch`, `http(s).get` or `.request`, axios, got, undici, -`requests`, `httpx`, urllib, with no exemption for a literal URL), `new URL` from +`requests`, `httpx`, urllib, Swift's `URLSession`, `URLRequest(`, `NWConnection` and Alamofire, with no exemption for a literal URL), `new URL` from input, redirect toggles, proxy settings and host allowlists, archive extraction and path traversal (`tar.x`, adm-zip, yauzl, extract-zip, `extractall`, `tar -x`, `unzip`, `path.join` or `resolve` on request or entry input, a `'..'` check added diff --git a/docs/skills.md b/docs/skills.md index dd53ccf96..14f1f399b 100644 --- a/docs/skills.md +++ b/docs/skills.md @@ -421,7 +421,7 @@ It runs an 80-item visual audit on your live site — in your Aside browser, so The self-regulation heuristic is tuned for design work — CSS-only changes get a free pass (they are inherently safe and reversible), but changes to component JSX/TSX files count against the risk budget. Hard cap at 30 fixes. If the risk score exceeds 20%, it stops and asks. -**Design detector.** When you have [impeccable](https://impeccable.style) installed, its engine runs first: on a URL the page's rendered DOM is dumped (linked styles inlined) and scanned; on a feature branch with no URL the changed frontend files are scanned (`.dart` files excepted: they count as frontend scope, but the engine reads web sources). Every mechanical finding arrives as a `FINDING-NNN` tagged with its rule id (`[nested-cards]`, `[low-contrast]`), and the report closes with `Detector: N → M`. gstack never runs impeccable's installer; when no engine is present it offers, once, to download the engine binary (checksum-pinned, logged in the egress ledger) and remembers the answer; without it the audit is unchanged. `gstack-config set design_detector off` disables the pre-pass. +**Design detector.** When you have [impeccable](https://impeccable.style) installed, its engine runs first: on a URL the page's rendered DOM is dumped (linked styles inlined) and scanned; on a feature branch with no URL the changed frontend files are scanned (Dart, Swift, Interface Builder, string-catalog and asset-catalog files excepted: they count as frontend scope, but the engine reads web sources). Every mechanical finding arrives as a `FINDING-NNN` tagged with its rule id (`[nested-cards]`, `[low-contrast]`), and the report closes with `Detector: N → M`. gstack never runs impeccable's installer; when no engine is present it offers, once, to download the engine binary (checksum-pinned, logged in the egress ledger) and remembers the answer; without it the audit is unchanged. `gstack-config set design_detector off` disables the pre-pass. ### Example @@ -631,7 +631,7 @@ Findings get action, not just listed. Obvious mechanical fixes (dead code, stale One exception: a shortcut you took deliberately and logged. A `gstack-shortcut(dec-)` marker whose decision id resolves in the decision ledger downgrades the finding to acknowledged debt. An orphan marker — one with no ledger entry behind it — doesn't suppress anything; the gap is reported normally and the marker itself gets flagged. -**Design pass.** When the diff touches frontend files, the Design specialist reads `review/design-checklist.md`, which is generated from `lib/design-catalog.ts`, so `/review`, `/ship`, and `/design-review` flag the same patterns under the same rule ids. If you have [impeccable](https://impeccable.style) installed, its engine scans the changed frontend files first (`.dart` files get the checklist pass only): its rows bucket by tier (auto-fix, ask, possible), a detector hit and a checklist hit at the same file:line collapse into one row, and your repo's `.impeccable/config*.json` ignores are read as settled decisions. Without it, the checklist pass runs alone. +**Design pass.** When the diff touches frontend files, the Design specialist reads `review/design-checklist.md`, which is generated from `lib/design-catalog.ts`, so `/review`, `/ship`, and `/design-review` flag the same patterns under the same rule ids. If you have [impeccable](https://impeccable.style) installed, its engine scans the changed frontend files first (Dart, Swift, Interface Builder, string-catalog and asset-catalog files get the checklist pass only): its rows bucket by tier (auto-fix, ask, possible), a detector hit and a checklist hit at the same file:line collapse into one row, and your repo's `.impeccable/config*.json` ignores are read as settled decisions. Without it, the checklist pass runs alone. **PR type.** The checklist starts by naming the kind of PR from the changed paths: docs-only, CI/infra, scripts/tooling, application or mixed, and the review's first line says which (`PR type: `). Application and mixed diffs run every category as before. A CI/infra, scripts/tooling or docs-only diff always gets Gate Integrity, Shell Injection, Completeness Gaps, Distribution & CI/CD Pipeline and Repo Conventions & Platform Fit; every other category with nothing to check is listed once, in one line, as not applicable, and never counts as passed. Repo Conventions & Platform Fit flags new files that don't match the languages and tools the repo already uses or the platforms its CI runs on, such as a `.bat` build script in a bash-and-Makefile repo. diff --git a/lib/frontend-scope.ts b/lib/frontend-scope.ts index 96c90806c..f0a5e4ec6 100644 --- a/lib/frontend-scope.ts +++ b/lib/frontend-scope.ts @@ -19,8 +19,13 @@ const EXTENSIONS = new Set([ // Dart: a Flutter widget and a repository share the extension, so the bash // script counts .dart as frontend AND backend; only the frontend half lives here. '.dart', + // Swift and Apple UI files (GST-3041): .swift is frontend and backend like .dart. + '.swift', '.storyboard', '.xib', '.strings', '.stringsdict', '.xcstrings', ]); +/** Native UI sources impeccable cannot read: frontend scope, never a design-scan target. */ +const NATIVE_UI = /\.(dart|swift|storyboard|xib|strings|stringsdict|xcstrings)$|\.xcassets\//; + // Root-level only: the bash arm's glob (`tailwind.config.*`) is matched against the // whole repo-relative path, so a nested `apps/web/tailwind.config.js` is not frontend there. const ROOT_CONFIG_PREFIXES = ['tailwind.config.', 'postcss.config.']; @@ -41,13 +46,20 @@ export function isTemplateCandidate(relPath: string): boolean { return TEMPLATE_EXT.test(rel) && !TEMPLATE_SKIP.test(rel) && !TEST_PATH.test(rel); } +/** A frontend path in a native UI format (Dart, Swift, Interface Builder, string and asset catalogs) rather than a web source. */ +export function isNativeUiPath(relPath: string): boolean { + return NATIVE_UI.test(relPath.replace(/\\/g, '/')); +} + /** Repo-relative path (forward slashes) → is it a frontend file per gstack-diff-scope? */ export function isFrontendPath(relPath: string): boolean { const rel = relPath.replace(/\\/g, '/').replace(/^\.\//, ''); const base = rel.slice(rel.lastIndexOf('/') + 1); const dot = base.lastIndexOf('.'); const ext = dot >= 0 ? base.slice(dot) : ''; // case-sensitive, exactly like gstack-diff-scope's globs + if (base === 'Package.swift') return false; // SwiftPM's manifest: config, never UI if (EXTENSIONS.has(ext)) return true; + if (rel.includes('.xcassets/')) return true; if (!rel.includes('/') && ROOT_CONFIG_PREFIXES.some(p => base.startsWith(p))) return true; if (rel.startsWith('app/views/')) return true; if (rel.includes('/components/')) return true; diff --git a/lib/review-risk.ts b/lib/review-risk.ts index 1403961d3..f413feaed 100644 --- a/lib/review-risk.ts +++ b/lib/review-risk.ts @@ -90,6 +90,7 @@ export const SECURITY_LINE = [ /['"`](?:node:)?child_process['"`]/, /(?:(?]))/, /\b(?:allowed|trusted|blocked|denied)[_-]?(?:hosts?|domains?|origins?|urls?)|\b(?:hosts?|domains?|origins?|urls?)[_-]?(?:allow|deny|block)[_-]?list/i, /\btar\.(?:x|extract)\s*\(|\.(?:extractall|extractAllTo|extractEntryTo)\s*\(|\b(?:tar|tf|zf|zip|archive)\.extract\s*\(|\bshutil\.unpack_archive\s*\(|\b(?:adm-zip|AdmZip|yauzl|extract-zip|unzipper|node-stream-zip)\b/, diff --git a/test/diff-scope.test.ts b/test/diff-scope.test.ts index b8fb6aa5b..2db37b873 100644 --- a/test/diff-scope.test.ts +++ b/test/diff-scope.test.ts @@ -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 }); diff --git a/test/fixtures/review-pins/files/lib/review-risk.ts.json b/test/fixtures/review-pins/files/lib/review-risk.ts.json index 1ee80cb2e..61b0e5c85 100644 --- a/test/fixtures/review-pins/files/lib/review-risk.ts.json +++ b/test/fixtures/review-pins/files/lib/review-risk.ts.json @@ -1 +1 @@ -{"sha":"25a7de61580398df96dca3651b10b2494825047e0898980406928b931b5f90af","replay":"GST-1350"} +{"sha":"2dbe134d502279da7a5f27e5370bb45a9658f01322030b1e27180d0e9e11285d","replay":"GST-3041"} diff --git a/test/fixtures/review-pins/replays/GST-3041.json b/test/fixtures/review-pins/replays/GST-3041.json new file mode 100644 index 000000000..dc2626ef7 --- /dev/null +++ b/test/fixtures/review-pins/replays/GST-3041.json @@ -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."} diff --git a/test/frontend-scope.test.ts b/test/frontend-scope.test.ts index 147e7d420..0cd036fd0 100644 --- a/test/frontend-scope.test.ts +++ b/test/frontend-scope.test.ts @@ -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', () => { diff --git a/test/gstack-design-detect.test.ts b/test/gstack-design-detect.test.ts index 84a4e4e62..a76e60080 100644 --- a/test/gstack-design-detect.test.ts +++ b/test/gstack-design-detect.test.ts @@ -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'); } diff --git a/test/review-plan-cli.test.ts b/test/review-plan-cli.test.ts index b4836f30f..ceadee1f2 100644 --- a/test/review-plan-cli.test.ts +++ b/test/review-plan-cli.test.ts @@ -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': 'NSAllowsArbitraryLoads\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'); diff --git a/test/review-risk-routing.test.ts b/test/review-risk-routing.test.ts index 66f3d8fa9..5f05c8867 100644 --- a/test/review-risk-routing.test.ts +++ b/test/review-risk-routing.test.ts @@ -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