Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/gstack-design-detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ──────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions bin/gstack-diff-scope
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;;
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions changelog.d/review-plan-sorts-swift-paths.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion docs/review-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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-<id>)` 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: <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.

Expand Down
12 changes: 12 additions & 0 deletions lib/frontend-scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.'];
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lib/review-risk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const SECURITY_LINE = [
/['"`](?:node:)?child_process['"`]/,
/(?:(?<![.\w$])|\b(?:globalThis|window|self)\.)fetch\s{0,20}\(/, /\bhttps?\.(?:request|get)\s{0,20}\(/, /\baxios\b/, /(?<![.\w$])got(?:\.[a-z]{1,10})?\s{0,20}\(/, /\bundici\b/,
/\b(?:requests|httpx)\.[a-z]{1,10}\s{0,20}\(/, /\burllib(?:3|\.request)?\b|\burlopen\s{0,20}\(/, /\bnew\s{1,20}URL\s{0,20}\(\s{0,20}(?!['"][^'"\\]{0,2000}['"]\s{0,20}\)|import\.meta\.url\s{0,20}\))/, /\b(?:urljoin|url\.resolve)\s{0,20}\(/,
/\bURLSession\b|\bURLRequest\s{0,20}\(|\bNWConnection\b|\bAlamofire\b|\bAF\.(?:request|download|upload|streamRequest)\s{0,20}\(/,
/\bredirect\s*:\s*['"](?:follow|manual)['"]|\b(?:maxRedirects|followRedirects?|follow_redirects|allow_redirects)\s*[:=]/,
/\b(?:HTTPS?_PROXY|NO_PROXY|ALL_PROXY|https?_proxy|no_proxy)\b|\b(?:Https?)?ProxyAgent\b|\bproxy\s*(?::|=(?![=>]))/, /\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/,
Expand Down
Loading
Loading