Skip to content

Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA

TypeScript

fix(review-risk): a design-token file is no longer a secret path by its name alone (GST-1350) (#3999)

Garry Tan7c0e396d1aca
diff --git a/changelog.d/garrytan-gst1350-token-secret-path.md b/changelog.d/garrytan-gst1350-token-secret-path.md
new file mode 100644
index 000000000..037d12558
--- /dev/null
+++ b/changelog.d/garrytan-gst1350-token-secret-path.md
@@ -0,0 +1,3 @@
+### Fixed
+
+- **A design-token file is no longer a secret path by its name alone, so a copy edit to one gets the review depth its content earns.** The review planner treated any path with a `token` or `tokens` segment as a secret path and a gate path, so founderstar's `scripts/ui/token.gd` (Godot UI design tokens) pushed a copy-only PR to the full panel with 11 readers. A token-named style or engine file (`.gd`, `.css`, `.scss`, `.sass`, `.less`, `.styl`) now counts as a secret path only when its added or removed lines hold a value the credential scanner behind pregate's secrets check reads as a secret, or have no text to read. Every other token file still counts by name. That covers code such as `lib/token.ts`, where auth tokens are minted and checked, and also `token.json`, `tokens.yaml` and binary token stores. Secrets, credentials and keychain names still count by name alone, and so do dotenv files (`.env`, `.env.production`, but not `.env.example`), SSH private keys (`id_rsa`, `id_ed25519`) and key-store files (`.pem`, `.key`, `.p12`, `.pfx`, `.jks`, `.keystore`, `.ppk`), which the planner didn't flag before.
diff --git a/docs/review-policy.md b/docs/review-policy.md
index da771522e..e0761fbc4 100644
--- a/docs/review-policy.md
+++ b/docs/review-policy.md
@@ -458,7 +458,7 @@ and matching is token-bounded: `costume` never reads as cost.
| money | a path segment naming cost, spend, budget, ledger, billing, price, fee or invoice; or a changed line with an identifier ending in `_usd` or `Usd`, unless every such name on the line is a reported cost (made only of words like cost, total, per, trial, mean or sum) and the line has no cap, limit, budget, spend, price, fee, charge, refund, amount, reservation or estimate word (the full list is `MONEY_USD_WORDS` in `lib/review-risk.ts`), no `<` or `>` comparison and no number set on it: summing or printing `cost_usd` is not money (GST-962); any `spend_cap` spelling; or a call to a paid provider `lib/pricing.ts` prices. A data file no code reads (the same consumer scan the depth uses) under a `doc/`, `docs/`, `wiki/`, `results/` or `reports/` directory counts as money only for a `spend_cap` or paid-provider line, never for its name, a `_usd` or `Usd` identifier (reported cost or not) or a metering word (GST-961); every other class still reads it |
| gate | a hunk the gate scan tagged: a relaxed threshold, a skipped test, a loosened check |
| auth | `SCOPE_AUTH` from `gstack-diff-scope`, on a code path with an auth, session, jwt, permission or role token in its name; a data file named for sessions (`recovered-sessions.jsonl`) outside a config location does not set `SCOPE_AUTH`, and `SCOPE_AUTH` fails safe: any name token containing auth sets it (`auth.ts`, `/auth/`, `oauth`, `useAuth.ts`, `nextauthmiddleware.ts`) except the authorship words `author`, `authors`, `authored`, `authoring`, `authorship`, `authority`, `authorities`, `coauthor` and `coauthors` |
-| secret | a secrets, credentials, keychain or token path, or a changed line that reads a key-named environment variable (`OPENAI_API_KEY`, `GH_TOKEN`) or a credential store |
+| secret | a secrets, credentials or keychain path, a dotenv file (`.env`, `.env.production`; not `.env.example`), an SSH private key (`id_rsa`) or a key-store extension (`.pem`, `.key`, `.p12`, `.pfx`, `.jks`, `.keystore`, `.ppk`), by name alone; a token-named path by name too, except a style or engine file (`token.gd`, `tokens.css`, `.scss`, `.sass`, `.less`, `.styl`), which counts only when its changed lines hold a value the credential scanner reads as a secret or have no text to read, since design and lexer tokens share the name (GST-1350); or a changed line that reads a key-named environment variable (`OPENAI_API_KEY`, `GH_TOKEN`) or a credential store |
An input the classifier cannot read (the diff, `gstack-diff-scope`, the gate
scan) fails closed to all four classes. `TARGETED_RULES` hashes the patterns.
diff --git a/lib/review-depth.ts b/lib/review-depth.ts
index 0a2c90963..a1379835c 100644
--- a/lib/review-depth.ts
+++ b/lib/review-depth.ts
@@ -13,7 +13,7 @@ import * as fs from 'node:fs';
import * as path from 'node:path';
import type { ResultCodeName } from './result-codes';
import { matchesAny } from './ship-policy';
-import { decodeCharRefs, DOC_SECRET_LINE, matchRisk, RISK_CLASSES, RISK_RULES, SVG_PATH, svgActive, type RiskClass } from './review-risk';
+import { decodeCharRefs, DOC_SECRET_LINE, matchRisk, RISK_CLASSES, RISK_RULES, SECRET_PATH, secretPath, SVG_PATH, svgActive, TOKEN_PATH, type RiskClass } from './review-risk';
export type DiffClass = 'docs' | 'tests' | 'code' | 'gate';
export type PathClass = 'docs' | 'tests' | 'code';
@@ -56,8 +56,8 @@ const RELEASE_METADATA = [/^CHANGELOG\.md$/, /^VERSION$/, /^agents-digest\//];
const HARNESS_PINS = /^scripts\/harness-pins\//;
/** Gate paths, the review-depth machinery included: an edit to how much review runs gets the most review. */
const GATE_PATH = [
- /(^|\/)\.github\/workflows\//, /(^|\/)(secrets?|credentials?|keychain|token[s]?)([._/-]|$)/i, /state-root/, /(^|\/)(pregate|gate|ship-receipt|ship-policy)[^/]*\.(ts|sh|json)$/, /(^|\/)bin\/gstack-(pregate|gate|ship-receipt|verify-gate|ci-gate)$/,
- /^lib\/review-(depth|collect|scope|targeted|risk|exclude)\.ts$/, /^lib\/default-base\.ts$/, /^review\/specialists\/targeted\.md$/, /^bin\/gstack-review-plan$/, /^lib\/ship-queue[^/]*\.ts$/, /^lib\/regen\.ts$/, /^\.gstack\/generated\.json$/, /^ship\/sections\/(review-army|adversarial)\.md\.tmpl$/, /^scripts\/resolvers\/review-army\.ts$/,
+ /(^|\/)\.github\/workflows\//, SECRET_PATH, /state-root/, /(^|\/)(pregate|gate|ship-receipt|ship-policy)[^/]*\.(ts|sh|json)$/, /(^|\/)bin\/gstack-(pregate|gate|ship-receipt|verify-gate|ci-gate)$/,
+ /^lib\/review-(depth|collect|scope|targeted|risk|exclude)\.ts$/, /^lib\/redact-(engine|patterns)\.ts$/, /^lib\/default-base\.ts$/, /^review\/specialists\/targeted\.md$/, /^bin\/gstack-review-plan$/, /^lib\/ship-queue[^/]*\.ts$/, /^lib\/regen\.ts$/, /^\.gstack\/generated\.json$/, /^ship\/sections\/(review-army|adversarial)\.md\.tmpl$/, /^scripts\/resolvers\/review-army\.ts$/,
];
/** The path rules lib/review-exclude.ts keeps a matched file for: a gate path, agent prose, or a data-shaped config file. */
@@ -193,12 +193,12 @@ export function classifyPath(p: string, root?: string | readonly string[]): Path
* classifyPath and every path-only caller keep data files code.
*/
export function dataCandidate(p: string, root?: string | readonly string[]): boolean {
- return DATA_PATH.test(p) && classifyPath(p, root) === 'code' && ![...AGENT_PROSE, ...GATE_PATH, ...DATA_CONFIG].some(r => r.test(p));
+ return DATA_PATH.test(p) && classifyPath(p, root) === 'code' && ![...AGENT_PROSE, ...GATE_PATH, TOKEN_PATH, ...DATA_CONFIG].some(r => r.test(p));
}
/** An SVG the data rule may move to docs once the collector reads its whole text as a drawing (ClassInput.drawings); never a data file another file is named through. */
export function svgCandidate(p: string, root?: string | readonly string[]): boolean {
- return SVG_PATH.test(p) && classifyPath(p, root) === 'code' && ![...AGENT_PROSE, ...GATE_PATH, ...DATA_CONFIG].some(r => r.test(p));
+ return SVG_PATH.test(p) && classifyPath(p, root) === 'code' && ![...AGENT_PROSE, ...GATE_PATH, TOKEN_PATH, ...DATA_CONFIG].some(r => r.test(p));
}
/** Whether a range needs the gate scan: any path that is not docs by the path-only rule. The data rule never skips it. */
@@ -257,7 +257,7 @@ export interface ClassResult { class: DiffClass; reasons: string[]; errors: Dept
const sanitize = (s: string) => s.replace(/[\0-\x1f]+/g, ' ').slice(0, 200);
const isOutput = (i: ClassInput, p: string) => !!i.registry?.outputs.length && matchesAny(i.registry.outputs, p);
export const unconsumedData = (i: Pick<ClassInput, 'consumed' | 'drawings' | 'root' | 'executables'>, p: string) => !i.executables?.includes(p) && Array.isArray(i.consumed) && !i.consumed.includes(p) && (dataCandidate(p, i.root) || (!!i.drawings?.includes(p) && svgCandidate(p, i.root)));
-const binaryData = (i: ClassInput, p: string) => !i.executables?.includes(p) && BINARY_DATA_PATH.test(p) && classifyPath(p, i.root) === 'code' && ![...AGENT_PROSE, ...GATE_PATH, ...DATA_CONFIG].some(r => r.test(p));
+const binaryData = (i: ClassInput, p: string) => !i.executables?.includes(p) && BINARY_DATA_PATH.test(p) && classifyPath(p, i.root) === 'code' && ![...AGENT_PROSE, ...GATE_PATH, TOKEN_PATH, ...DATA_CONFIG].some(r => r.test(p));
const pathClass = (i: ClassInput, p: string): PathClass => i.executables?.includes(p) && !i.excluded?.has(p) ? 'code' : (i.excluded?.has(p) || (i.stampOnly ?? []).includes(p) || unconsumedData(i, p) || binaryData(i, p) ? 'docs' : classifyPath(p, i.root));
/** The diff's class, raised to gate by any gate signal; `errors` lists every input that fails the depth closed; `runtimeLines` counts code-class lines outside the base registry's outputs. */
@@ -286,7 +286,7 @@ export function classifyDiff(i: ClassInput): ClassResult {
if (CLASS_RANK[cls] >= CLASS_RANK.code) {
if (s.SCOPE_AUTH === 'true') raise('gate', 'auth paths');
if (s.SCOPE_MIGRATIONS === 'true') raise('gate', 'migrations');
- for (const p of i.paths) if (GATE_PATH.some(r => r.test(p))) { raise('gate', `gate path: ${p}`); break; }
+ for (const p of i.paths) if (GATE_PATH.some(r => r.test(p)) || secretPath(p, [...(i.added?.[p] ?? []), ...(i.removed?.[p] ?? [])])) { raise('gate', `gate path: ${p}`); break; }
if (i.registry?.error) errors.push(i.registry.error);
}
const riskHits = CLASS_RANK[cls] >= CLASS_RANK.code ? matchRisk({ codePaths: i.paths.filter(p => pathClass(i, p) === 'code'), executables: i.executables, added: i.added, removed: i.removed, scopeAuth: s.SCOPE_AUTH === 'true', ...(i.riskPaths?.length ? { isRiskPath: (p: string) => matchesAny(i.riskPaths!, p) && !DATA_PATH.test(p) } : {}) }) : new Map<RiskClass, string>();
diff --git a/lib/review-exclude.ts b/lib/review-exclude.ts
index 78d9131f6..4a6fc00bf 100644
--- a/lib/review-exclude.ts
+++ b/lib/review-exclude.ts
@@ -24,6 +24,7 @@ import * as os from 'node:os';
import * as path from 'node:path';
import { collectLive } from './review-collect';
import { DATA_PATH, classifyPath, isAgentProse, isDataConfig, isGatePath, type PathLines } from './review-depth';
+import { secretPath } from './review-risk';
import { secretLine } from './review-targeted';
import { cmpVersion, parseVersion } from './version-source';
import { REVIEW_EXCLUDE_KEY_VERSION, SHIP_POLICY_PATH, isUnavailable, policyUnavailableLine } from './ship-policy';
@@ -215,7 +216,7 @@ const BINARY_CONTENT_EXT = /\.(?:png|jpe?g|gif|webp|bmp|ico|avif|tiff?|heic|heif
/** Why a matched file is kept by its path, mode and lines alone; null for content the policy may exclude. A binary file readers would only see as "Binary files differ" is content unless its directory, mode, gate tags, extension or magic keep it. */
function pathReason(i: ExcludeInput, p: string, m: Matched, binary: ReadonlySet<string>, native: ReadonlySet<string>): KeptReason | null {
if (/^\.(gstack|github)\//.test(p)) return 'policy-dir';
- if (isGatePath(p)) return 'gate-path';
+ if (isGatePath(p) || secretPath(p, i.added[p] ?? [])) return 'gate-path';
if (m.oldMode === '100755' || m.newMode === '100755') return 'executable';
if ([m.oldMode, m.newMode].some(x => x === '120000' || x === '160000')) return 'link';
if (i.gateTagged?.has(p)) return 'gate-tagged';
diff --git a/lib/review-risk.ts b/lib/review-risk.ts
index 40d263ee3..1403961d3 100644
--- a/lib/review-risk.ts
+++ b/lib/review-risk.ts
@@ -11,6 +11,8 @@
* foreignObject element, an event handler, a javascript: URL; character references decoded) is security (GST-911).
*/
import { createHash } from 'node:crypto';
+import { scan } from './redact-engine';
+import { PATTERNS } from './redact-patterns';
export const RISK_CLASSES = ['money', 'auth', 'secret', 'security', 'data', 'eval', 'policy'] as const;
export type RiskClass = (typeof RISK_CLASSES)[number];
@@ -60,7 +62,17 @@ export const usdMoney = (line: string) => {
};
export const AUTH_PATH_TOKENS = ['auth', 'authn', 'authz', 'oauth', 'oauth2', 'jwt', 'session', 'sessions', 'permission', 'permissions', 'role', 'roles'];
export const AUTH_PATH_PREFIXES = ['authenticat', 'authoriz'];
-export const SECRET_PATH = /(^|\/)(secrets?|credentials?|keychain|token[s]?)([._/-]|$)/i;
+/** A secret path by name alone: a secrets, credentials or keychain name, a dotenv file (not a template), an SSH private key or a key-store extension. */
+export const SECRET_PATH = /(^|\/)(secrets?|credentials?|keychain)([._/-]|$)|(^|\/)(\.env(\.(?!(example|sample|template)$)[^/]+)?|id_(rsa|dsa|ecdsa|ed25519)|\.netrc|\.pgpass|\.htpasswd)$|\.(pem|key|p12|pfx|jks|keystore|ppk)$/i;
+/** A token name (design, lexer and LLM tokens as well as auth tokens, GST-1350: founderstar's scripts/ui/token.gd): a secret path by name unless it is a TOKEN_SOURCE file, which its changed lines decide. */
+export const TOKEN_PATH = /(^|\/)tokens?([._/-]|$)/i;
+/** Style and engine extensions: a token-named file of one of these holds design tokens. Any other token file (code, json, yaml, no extension, binary) stays a secret path by name. */
+export const TOKEN_SOURCE = /\.(gd|css|scss|sass|less|styl)$/i;
+/** The secret-category patterns of the credential scanner pregate's secrets check runs (lib/redact-engine.ts): RISK_RULES and TARGETED_RULES hash them. */
+export const SECRET_SCAN = PATTERNS.filter(r => r.category === 'secret').map(r => [r.id, r.tier, '/' + r.regex.source + '/' + r.regex.flags]);
+const secretShaped = (p: string, lines: readonly string[]) => scan(lines.join('\n'), { processEnv: {}, sourcePath: p }).findings.some(f => f.category === 'secret' && f.severity !== 'LOW');
+/** Whether a changed path is a secret path: by name, or a token-named style or engine file whose added or deleted lines hold a secret-shaped value or cannot be read (no text lines fails closed). */
+export const secretPath = (p: string, lines: readonly string[] = []) => SECRET_PATH.test(p) || (TOKEN_PATH.test(p) && (!TOKEN_SOURCE.test(p) || !lines.length || secretShaped(p, lines)));
/** An environment name whose underscore-separated segments include a key word: OPENAI_API_KEY, GH_TOKEN; never MAX_TOKENS. */
export const KEY_NAME = String.raw`(?:[A-Z0-9]+_)*(?:API_?KEY|SECRET|TOKEN|PASSWORD|PASSWD|PRIVATE_KEY|ACCESS_KEY|CREDENTIALS?)(?:_[A-Z0-9]+)*\b`;
export const SECRET_LINE = [
@@ -141,7 +153,8 @@ const namesMoney = (t: readonly string[], words: readonly string[]) => t.some(x
export const RISK_RULES = createHash('sha256').update(JSON.stringify({
RISK_CLASSES, MONEY_PATH_TOKENS, AUTH_PATH_TOKENS, AUTH_PATH_PREFIXES, KEY_NAME, SECURITY_PATH_TOKENS, DATA_PATH_TOKENS, EVAL_PATH_TOKENS,
MONEY_LINE_TOKENS, MONEY_PAIRS, SPEND_PAIRS, REPORTED_COST_WORDS, MONEY_USD_WORDS,
- patterns: Object.entries({ PROSE_PATH: [PROSE_PATH], DOC_SECRET_LINE, CONFIG_DATA_PATH: [CONFIG_DATA_PATH], STATS_SCRIPT: [STATS_SCRIPT], MONEY_LINE, PAID_MONEY_LINE, USD_COMPARE, RESULTS_TREE: [RESULTS_TREE], PRICE_USD_KEY: [PRICE_USD_KEY], PRICE_KEY_EXEMPT: [PRICE_KEY_EXEMPT], SECRET_LINE, SECRET_PATH: [SECRET_PATH], SECURITY_LINE, SECURITY_JOINED, DATA_LINE, SVG_PATH: [SVG_PATH], SVG_ACTIVE }).map(([k, v]) => [k, v.map(r => '/' + r.source + '/' + r.flags)]),
+ SECRET_SCAN,
+ patterns: Object.entries({ PROSE_PATH: [PROSE_PATH], DOC_SECRET_LINE, CONFIG_DATA_PATH: [CONFIG_DATA_PATH], STATS_SCRIPT: [STATS_SCRIPT], MONEY_LINE, PAID_MONEY_LINE, USD_COMPARE, RESULTS_TREE: [RESULTS_TREE], PRICE_USD_KEY: [PRICE_USD_KEY], PRICE_KEY_EXEMPT: [PRICE_KEY_EXEMPT], SECRET_LINE, SECRET_PATH: [SECRET_PATH], TOKEN_PATH: [TOKEN_PATH], TOKEN_SOURCE: [TOKEN_SOURCE], SECURITY_LINE, SECURITY_JOINED, DATA_LINE, SVG_PATH: [SVG_PATH], SVG_ACTIVE }).map(([k, v]) => [k, v.map(r => '/' + r.source + '/' + r.flags)]),
})).digest('hex').slice(0, 16);
export const tokens = (p: string) => p.replace(/([a-z0-9])([A-Z])/g, '$1 $2').toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
@@ -174,7 +187,7 @@ export function matchRisk(i: RiskInput): Map<RiskClass, string> {
const pathOnly = config || stats;
const prose = PROSE_PATH.test(p);
if (i.scopeAuth && t.some(x => AUTH_PATH_TOKENS.includes(x) || AUTH_PATH_PREFIXES.some(a => x.startsWith(a)))) hit('auth', 'auth path: ' + p);
- if (SECRET_PATH.test(p)) hit('secret', 'secret path: ' + p);
+ if (secretPath(p, [...(i.added?.[p] ?? []), ...(i.removed?.[p] ?? [])])) hit('secret', 'secret path: ' + p);
const money = !(i.dataPaths?.includes(p) && RESULTS_TREE.test(p));
if (money && namesMoney(t, MONEY_PATH_TOKENS)) hit('money', 'money path: ' + p);
if (t.some(x => SECURITY_PATH_TOKENS.includes(x))) hit('security', 'security path: ' + p);
diff --git a/lib/review-targeted.ts b/lib/review-targeted.ts
index 6eaea7f5e..ce8e040ef 100644
--- a/lib/review-targeted.ts
+++ b/lib/review-targeted.ts
@@ -21,7 +21,7 @@ import { createHash } from 'node:crypto';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { classifyPath, unconsumedData, type ClassInput } from './review-depth';
-import { AUTH_PATH_PREFIXES, AUTH_PATH_TOKENS, KEY_NAME, MONEY_LINE, MONEY_LINE_TOKENS, MONEY_PAIRS, MONEY_PATH_TOKENS, MONEY_USD_WORDS, PROSE_PATH, REPORTED_COST_WORDS, RESULTS_TREE, SECRET_LINE, SECRET_PATH, SPEND_PAIRS, USD_COMPARE, matchRisk } from './review-risk';
+import { AUTH_PATH_PREFIXES, AUTH_PATH_TOKENS, KEY_NAME, MONEY_LINE, MONEY_LINE_TOKENS, MONEY_PAIRS, MONEY_PATH_TOKENS, MONEY_USD_WORDS, PROSE_PATH, REPORTED_COST_WORDS, RESULTS_TREE, SECRET_LINE, SECRET_PATH, SECRET_SCAN, SPEND_PAIRS, TOKEN_PATH, TOKEN_SOURCE, USD_COMPARE, matchRisk } from './review-risk';
export const TARGETED_CLASSES = ['money', 'gate', 'auth', 'secret'] as const;
export type TargetedClass = (typeof TARGETED_CLASSES)[number];
@@ -31,8 +31,8 @@ export const secretLine = (line: string) => SECRET_LINE.some(r => r.test(line));
/** A hash of the patterns that decide the classes, not of this file's bytes: a comment edit keeps it, a pattern edit changes it. */
export const TARGETED_RULES = createHash('sha256').update(JSON.stringify({
- TARGETED_CLASSES, MONEY_PATH_TOKENS, MONEY_LINE_TOKENS, MONEY_PAIRS, SPEND_PAIRS, REPORTED_COST_WORDS, MONEY_USD_WORDS, AUTH_PATH_TOKENS, AUTH_PATH_PREFIXES, KEY_NAME,
- patterns: Object.entries({ MONEY_LINE, USD_COMPARE, RESULTS_TREE: [RESULTS_TREE], SECRET_LINE, SECRET_PATH: [SECRET_PATH], PROSE_PATH: [PROSE_PATH] }).map(([k, v]) => [k, v.map(r => `/${r.source}/${r.flags}`)]),
+ TARGETED_CLASSES, MONEY_PATH_TOKENS, MONEY_LINE_TOKENS, MONEY_PAIRS, SPEND_PAIRS, REPORTED_COST_WORDS, MONEY_USD_WORDS, AUTH_PATH_TOKENS, AUTH_PATH_PREFIXES, KEY_NAME, SECRET_SCAN,
+ patterns: Object.entries({ MONEY_LINE, USD_COMPARE, RESULTS_TREE: [RESULTS_TREE], SECRET_LINE, SECRET_PATH: [SECRET_PATH], TOKEN_PATH: [TOKEN_PATH], TOKEN_SOURCE: [TOKEN_SOURCE], PROSE_PATH: [PROSE_PATH] }).map(([k, v]) => [k, v.map(r => `/${r.source}/${r.flags}`)]),
})).digest('hex').slice(0, 16);
export interface TargetedInput {
diff --git a/test/fixtures/review-pins/files/lib/review-depth.ts.json b/test/fixtures/review-pins/files/lib/review-depth.ts.json
index ec642a911..e16c7705b 100644
--- a/test/fixtures/review-pins/files/lib/review-depth.ts.json
+++ b/test/fixtures/review-pins/files/lib/review-depth.ts.json
@@ -1 +1 @@
-{"sha":"706cf48d3cfac586484c68160e292955752c55ed14bdc06856be0ef8ac5e61c6","replay":"GSTA-258-L7+GST-961+962+GST-972+GEVA-223"}
+{"sha":"e8940804d37c63cd11284461b5aa0235bfd23ec50cc2df6baa4f15e8d9cef124","replay":"GST-1350"}
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 ae58ef817..1ee80cb2e 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":"d4a16e78c76f4346ef3a4ce792c47c6ef5b4c2574f2474f50e7046f89cb2bc69","replay":"GSTA-258-L7+GST-961+962"}
+{"sha":"25a7de61580398df96dca3651b10b2494825047e0898980406928b931b5f90af","replay":"GST-1350"}
diff --git a/test/fixtures/review-pins/replays/GST-1350.json b/test/fixtures/review-pins/replays/GST-1350.json
new file mode 100644
index 000000000..5493024b1
--- /dev/null
+++ b/test/fixtures/review-pins/replays/GST-1350.json
@@ -0,0 +1 @@
+{"replay":"GST-1350","justification":"GST-1350 no-loss check (test/review-risk-token-paths.test.ts, 'GST-1350 no-loss check'): a token-named style or engine file (gd, css, scss, sass, less, styl: TOKEN_SOURCE) is a secret and gate path only when its changed lines hold a secret the credential scanner reads or have no text; every other token-named file (code such as lib/token.ts, json, yaml, binary) stays a secret path by name as on main; dotenv files, SSH private keys and key-store extensions become secret and gate paths by name; lib/redact-engine.ts and lib/redact-patterns.ts become gate paths. On the GST-967 history grid over eleven cases (3,168 planReview cases with targetedClasses), stand-in paths reproduce main's plans at b244e6d byte for byte (bafc2b53). On the real paths the branch lowers only the two benign token-named style and engine cases (scripts/ui/token.gd, ui/tokens.css: gate/full to code/light, the fix); theme/token.ts, a token file holding a key-shaped value, token.json, a binary tokens.db, secrets/ and credentials.json keep main's plans, and .env, id_rsa and server.pem rise from code/light to gate/full keeping every reader main dispatched, with GST-972's Red Team split (252 checklist slots of light's batched reader move to full depth's batched reader at the specialist effort while the Red Team keeps full effort as its own dispatch). Over the last 100 first-parent main commits to b244e6d (288 histories each, 28,800 plans, collectCommit with scope {} and gate scan 0), the branch plans what main planned on 98; the other two (0b19a36, 5fdfa14, both editing lib/redact-patterns.ts) rise from code/full to gate/full, drop no reader and lower no effort (71 of 288 histories gain the Step 11 voices). No commit in that range touches a token-named, dotenv or key path"}
diff --git a/test/review-exclude.test.ts b/test/review-exclude.test.ts
index 3709807de..cc50440b4 100644
--- a/test/review-exclude.test.ts
+++ b/test/review-exclude.test.ts
@@ -431,10 +431,22 @@ describe('a branch cannot hide code under a base pattern', () => {
for (const [rel, bytes] of Object.entries({ ...kept, ...content })) fs.writeFileSync(path.join(repo.work, rel), bytes);
commit(repo, {});
const p = JSON.parse(plan(repo, ['--json']).out);
- expect(p.review_exclude.kept_files).toEqual(Object.keys(kept).map(f => ({ path: f, reason: 'code' })));
+ expect(p.review_exclude.kept_files).toEqual(Object.keys(kept).map(f => ({ path: f, reason: /id_ed25519|\.p12$/.test(f) ? 'gate-path' : 'code' })));
expect(p.review_exclude).toMatchObject({ excluded: 2, content: { binary: 2 } });
}, 120_000);
+ // Value: protects=a binary token store under an excluded glob stays in every reader's diff (GST-1350 narrowed the token name
+ // rule to source and style files); fails_when=a token-named binary with no text lines is excluded as content; seam=bin/gstack-review-plan
+ test('a binary token store under an excluded glob is kept as a gate path', () => {
+ const repo = makeFixtureRepo({ prefix: 'gstack-exclude-', baseFiles: { '.gstack/ship-policy.json': policyText(['assets/**']) } }); repos.push(repo);
+ fs.mkdirSync(path.join(repo.work, 'assets'), { recursive: true });
+ for (const rel of ['assets/tokens.db', 'assets/shot.png']) fs.writeFileSync(path.join(repo.work, rel), GZ);
+ commit(repo, {});
+ const p = JSON.parse(plan(repo, ['--json']).out);
+ expect(p.review_exclude.kept_files).toEqual([{ path: 'assets/tokens.db', reason: 'gate-path' }]);
+ expect(p.review_exclude).toMatchObject({ excluded: 1, content: { binary: 1 } });
+ }, 120_000);
+
// Value: protects=a branch's .gitattributes cannot get a matched file with a credential line excluded by making git call it
// binary, at the plan (live tree) and at the receipt (head blobs); fails_when=the secret-line rule reads only the
// collector's added lines, which git leaves empty for an attribute-binary file, so the file is excluded; why_new=GST-972
diff --git a/test/review-risk-linear.test.ts b/test/review-risk-linear.test.ts
index ef19c7f19..bd9645ef8 100644
--- a/test/review-risk-linear.test.ts
+++ b/test/review-risk-linear.test.ts
@@ -49,7 +49,7 @@ describe('the rules hashes cover every new pattern', () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'risk-rules-'));
try {
for (const f of ['review-depth.ts', 'review-risk.ts']) fs.copyFileSync(path.join(ROOT, 'lib', f), path.join(dir, f));
- fs.symlinkSync(path.join(ROOT, 'lib/ship-policy.ts'), path.join(dir, 'ship-policy.ts'));
+ for (const f of ['ship-policy.ts', 'redact-engine.ts', 'redact-patterns.ts']) fs.symlinkSync(path.join(ROOT, 'lib', f), path.join(dir, f));
fs.writeFileSync(path.join(dir, 'print.ts'), "import { DEPTH_RULES } from './review-depth';\nconsole.log(DEPTH_RULES);\n");
const hash = () => {
const r = spawnSync(process.execPath, [...bunIsolationArgs(), path.join(dir, 'print.ts')], { encoding: 'utf8', timeout: 30_000 });
diff --git a/test/review-risk-token-paths.test.ts b/test/review-risk-token-paths.test.ts
new file mode 100644
index 000000000..4e96b1300
--- /dev/null
+++ b/test/review-risk-token-paths.test.ts
@@ -0,0 +1,191 @@
+/**
+ * GST-1350 (FOUN-32, FOUN-87): founderstar's scripts/ui/token.gd is a Godot UI design-token file, and the secret-path
+ * rule matched its name alone, so a copy-only PR (founderstar#546) was gate class at full depth. A token-named file is a
+ * secret path only when its changed lines hold a secret-shaped value; a secrets or credentials name, a key file or a
+ * dotenv file stays a secret path by name.
+ */
+import { afterEach, describe, expect, test } from 'bun:test';
+import { spawnSync } from 'node:child_process';
+import * as fs from 'node:fs';
+import * as os from 'node:os';
+import * as path from 'node:path';
+import { collectCommit } from '../lib/review-collect';
+import { createHash } from 'node:crypto';
+import { depthOfCommitInput, isGatePath, planReview, ROLE_EFFORT, scanNumbers } from '../lib/review-depth';
+import { matchRisk, secretPath } from '../lib/review-risk';
+import { targetedClasses } from '../lib/review-targeted';
+
+const GODOT_TOKENS = ['class_name UIToken', 'extends RefCounted', 'const COLOR_PRIMARY := Color("#ff6a00")', 'const SPACING_MD := 12', 'const LABEL_PLAY := "Play"'];
+const BENIGN: Record<string, string[]> = {
+ 'scripts/ui/token.gd': GODOT_TOKENS,
+ 'design-tokens.json': ['{ "color": { "primary": "#ff6a00" }, "space": { "md": 12 } }'],
+ 'ui/tokens.css': [':root { --color-primary: #ff6a00; --space-md: 12px; }'],
+};
+/** Built at run time so the credential scan never reads a key-shaped literal in this file. */
+const fakePat = () => ['ghp', '_', 'x7Qm2Lp9Vr4Tn8Kw3Hs6', 'Jd1Fz5Bc0YaUe4Gq'].join('');
+const googleToken = () => JSON.stringify({ token: 'ya29.' + 'x'.repeat(60), refresh_token: '1//0' + 'y'.repeat(40) });
+const NAMED: Record<string, string[]> = {
+ 'token.json': [googleToken()],
+ 'auth/token': ['z'.repeat(40)],
+ 'config/tokens.yaml': ['primary: ff6a00'],
+ 'cache/tokens.db': [],
+ 'theme/token.ts': ['export const token = { colorPrimary: "#ff6a00", spaceMd: 12 };'],
+ 'lib/token.ts': ['const API_TOKEN = "' + ['Zx9Qw8Er7Ty6Ui5Op4', 'As3Df2Gh1Jk0Lm'].join('') + '";'],
+ '.env': ['LOG_LEVEL=debug'],
+ 'deploy/.env.production': ['LOG_LEVEL=info'],
+ '.ssh/id_rsa': ['not shown'],
+ 'certs/server.pem': ['not shown'],
+ 'credentials.json': ['{ "type": "service_account" }'],
+ 'secrets/prod.yaml': ['region: us-east-1'],
+};
+
+const risk = (p: string, added: string[]) => matchRisk({ codePaths: [p], added: { [p]: added }, scopeAuth: false });
+const depth = (p: string, added: string[]) => depthOfCommitInput({ paths: [p], added: { [p]: added }, removed: {}, gateTagged: 0, scope: {} });
+
+describe('GST-1350: a token-named file is a secret path only on secret-shaped content', () => {
+ // Value: protects=design-token files (token.gd, design-tokens.json, tokens.css) review at the depth their content earns;
+ // fails_when=the token name alone raises the secret class, the gate class or a kept gate path; seam=matchRisk + classifyDiff + isGatePath
+ test.each(Object.entries(BENIGN))('%s with design tokens is not secret, not gate', (p, added) => {
+ expect(risk(p, added).has('secret')).toBe(false);
+ expect(isGatePath(p)).toBe(false);
+ const d = depth(p, added);
+ expect(d.class).not.toBe('gate');
+ expect(d.risk).not.toContain('secret');
+ });
+
+ // Value: protects=a token file that carries a credential still gets the secret class and the gate class;
+ // fails_when=the content check misses a key-shaped value on an added or a removed line; seam=matchRisk + classifyDiff
+ test.each(['scripts/ui/token.gd', 'ui/tokens.css'])('%s holding a secret-shaped value stays secret and gate', p => {
+ const line = `const API_TOKEN := "${fakePat()}"`;
+ expect(risk(p, [...BENIGN[p]!, line]).get('secret')).toBe('secret path: ' + p);
+ expect(matchRisk({ codePaths: [p], added: {}, removed: { [p]: [line] }, scopeAuth: false }).has('secret')).toBe(true);
+ const d = depth(p, [line]);
+ expect(d.class).toBe('gate');
+ expect(d.risk).toContain('secret');
+ });
+
+ // Value: protects=secret and credential names, private keys, dotenv files and token files that are not style or engine files
+ // (code such as token.ts, json, yaml, no extension, binary) stay secret by name, whatever they hold; fails_when=narrowing the token rule drops one of them, or a key file reads as anything below gate; seam=matchRisk + classifyDiff + isGatePath
+ test.each(Object.entries(NAMED))('%s stays secret and gate by name alone', (p, added) => {
+ expect(risk(p, added).get('secret')).toBe('secret path: ' + p);
+ expect(isGatePath(p) || secretPath(p, added)).toBe(true);
+ const d = depth(p, added);
+ expect(d.class).toBe('gate');
+ expect(d.risk).toContain('secret');
+ });
+
+ // Value: protects=a token-named style or engine file whose lines cannot be read (binary, no text) fails closed to a secret path;
+ // fails_when=an empty line set reads as benign; seam=matchRisk
+ test('a token-named style or engine file with no readable lines stays secret', () => {
+ expect(risk('scripts/ui/token.gd', []).has('secret')).toBe(true);
+ expect(matchRisk({ codePaths: ['ui/tokens.css'], scopeAuth: false }).has('secret')).toBe(true);
+ });
+
+ // Value: protects=a dotenv template holds no secrets by convention; fails_when=.env.example raises the secret class on its name; seam=matchRisk
+ test('.env.example is not a secret path by name', () => {
+ expect(risk('.env.example', ['OPENAI_API_KEY=']).has('secret')).toBe(false);
+ });
+});
+
+describe('GST-1350: founderstar#546 shape, a copy-only edit to a Godot token file', () => {
+ const dirs: string[] = [];
+ afterEach(() => { while (dirs.length) fs.rmSync(dirs.pop()!, { recursive: true, force: true }); });
+
+ // Value: protects=the planner gives a copy-only token.gd change the light depth it earns (no 11-reader full panel);
+ // fails_when=collectCommit + targetedClasses + depthOfCommitInput read the token name as a secret or gate path; seam=gstack-diff-scope + collectCommit + targetedClasses + depthOfCommitInput
+ test('the planner: no secret class, no gate class, light depth', () => {
+ const root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'token-path-')));
+ dirs.push(root);
+ const env = { ...process.env, GIT_AUTHOR_NAME: 't', GIT_AUTHOR_EMAIL: 't@t', GIT_COMMITTER_NAME: 't', GIT_COMMITTER_EMAIL: 't@t', GIT_CONFIG_GLOBAL: path.join(root, 'gitconfig'), GIT_CONFIG_NOSYSTEM: '1' };
+ fs.writeFileSync(path.join(root, 'gitconfig'), '[commit]\n\tgpgsign = false\n[init]\n\tdefaultBranch = main\n');
+ const sh = (c: string) => { const r = spawnSync('bash', ['-c', c], { cwd: root, env, encoding: 'utf8', timeout: 60_000 }); if (r.status !== 0) throw new Error(`${c}: ${r.stderr}`); return r.stdout.trim(); };
+ const file = path.join(root, 'scripts/ui/token.gd');
+ fs.mkdirSync(path.dirname(file), { recursive: true });
+ fs.writeFileSync(file, GODOT_TOKENS.join('\n') + '\n');
+ sh('git init -q && git add -A && git commit -qm base');
+ const base = sh('git rev-parse HEAD');
+ fs.writeFileSync(file, GODOT_TOKENS.join('\n').replace('"Play"', '"Start game"') + '\n');
+ sh('git commit -qam copy');
+ const c = collectCommit(root, base, sh('git rev-parse HEAD'));
+ expect(targetedClasses({ ...c, scope: {}, gateTagged: 0 }).classes).toEqual([]);
+ const d = depthOfCommitInput({ ...c, scope: {}, gateTagged: 0 });
+ expect({ class: d.class, depth: d.depth, risk: d.risk }).toEqual({ class: 'code', depth: 'light', risk: [] });
+ }, 60_000);
+});
+
+/**
+ * The GST-1350 no-loss check (crew rule 2026-10-30; replay 'GST-1350' in test/fixtures/review-pins/replays/GST-1350.json).
+ * On the GST-967 history grid (288 histories per case), each case runs on its real path and on a stand-in (a path main and the
+ * branch both classify the way main classified the real one). Main's planReview at b244e6d (v1.95.5.0) on the real paths, with
+ * targetedClasses as the planner computes them, hashes to MAIN_1350_PLANS, and so does the branch's on the stand-ins. On the
+ * real paths the branch lowers exactly the two benign token-named style and engine cases (gate/full to code/light, the fix) and only raises
+ * or keeps every other case, keeping every reader main dispatched there at the same effort or higher, with GST-972's one
+ * exception: light's batched reader, which carries the Red Team prompt at full effort, becomes full depth's batched reader at
+ * the specialist effort on the three key files that rise to full, while the Red Team keeps full effort as its own dispatch.
+ */
+const MAIN_1350_PLANS = 'bafc2b5329237dbb994ab85d5ee0a696e7bd479615f81206c9b4ce7507af108e';
+describe('GST-1350 no-loss check', () => {
+ // Value: protects=the no-loss rule for review-depth changes: narrowing the token name drops readers only on benign token files;
+ // fails_when=a stand-in stops matching main's plans, a token file with a secret or a secrets, credentials or key file loses a
+ // reader or a class, or another case moves down; why_new=GST-1350; seam=targetedClasses + planReview; no_claim=what the readers find
+ test('only benign token files move down; every other case keeps or raises main\'s plan', () => {
+ const sha = (x: unknown) => createHash('sha256').update(JSON.stringify(x)).digest('hex');
+ const none = scanNumbers({});
+ const gd = ['class_name UIToken', 'const LABEL_PLAY := "Start game"'];
+ const cases: Record<string, [string, string, string[]]> = {
+ 'token-gd': ['scripts/ui/token.gd', 'scripts/ui/credentials.gd', gd],
+ 'tokens-css': ['ui/tokens.css', 'ui/secrets.css', [':root { --space-md: 12px; }']],
+ 'token-ts': ['theme/token.ts', 'theme/credentials.ts', ['export const token = { spaceMd: 12 };']],
+ 'token-secret': ['scripts/ui/token.gd', 'scripts/ui/credentials.gd', [...gd, `const API_TOKEN := "${fakePat()}"`]],
+ pem: ['certs/server.pem', 'certs/server.crt', ['not shown']],
+ dotenv: ['.env', '.envrc', ['LOG_LEVEL=debug']],
+ 'id-rsa': ['.ssh/id_rsa', '.ssh/id_rsa.pub', ['not shown']],
+ 'secrets-dir': ['secrets/prod.yaml', 'secrets/prod.yaml', ['region: us-east-1']],
+ 'credentials-json': ['credentials.json', 'credentials.json', ['{ "type": "service_account" }']],
+ 'token-json': ['token.json', 'token.json', [googleToken()]],
+ 'tokens-db': ['cache/tokens.db', 'cache/tokens.db', []],
+ };
+ type Row = { name: string; fullPasses: number; last: string; bits: number; adversarialRan: boolean; targeted: string[]; class: string; depth: string; step: string; dispatches: { role: string; name: string; effort: string; checklists: string[] }[] };
+ const grid = (pick: 0 | 1) => {
+ const rows: Row[] = [];
+ for (const [name, c] of Object.entries(cases)) {
+ const paths = [c[pick]];
+ const added = { [c[pick]]: c[2] };
+ const t = targetedClasses({ paths, added, removed: {}, scope: {}, gateTagged: 0, consumed: [] }).classes;
+ for (const fullPasses of [0, 1, 2]) for (const last of ['none', 'full', 'fix-check'] as const) for (let bits = 0; bits < 16; bits++) for (const adversarialRan of [false, true]) {
+ const history = { fullPasses, last, fixedBlocking: !!(bits & 1), fixedBelow: !!(bits & 2), blockingOpen: !!(bits & 4), touchedGate: !!(bits & 8) };
+ const p = planReview({ paths, added, removed: {}, scope: {}, gateTagged: 0, diffLines: 40, consumed: [], numbers: none, history, adversarialRan, targeted: { classes: t } });
+ rows.push({ name, fullPasses, last, bits, adversarialRan, targeted: t, class: p.class, depth: p.depth, step: p.next.step, dispatches: p.dispatches.map(d => ({ role: d.role, name: d.name, effort: d.effort, checklists: d.checklists ?? [] })) });
+ }
+ }
+ return rows;
+ };
+ const main = grid(1);
+ expect(sha(main)).toBe(MAIN_1350_PLANS);
+ const rank: Record<string, number> = { docs: 0, tests: 1, code: 2, gate: 3, light: 0, standard: 1, full: 2 };
+ const effort: Record<string, number> = { medium: 1, full: 2, host: 2 };
+ const lowered = new Set(['token-gd', 'tokens-css']);
+ const moves: Record<string, number> = {};
+ let split = 0;
+ grid(0).forEach((b, i) => {
+ const m = main[i]!;
+ const move = `${m.name}: ${m.class}/${m.depth} -> ${b.class}/${b.depth}`;
+ moves[move] = (moves[move] ?? 0) + 1;
+ if (lowered.has(m.name)) return;
+ expect([move, rank[b.class]! >= rank[m.class]!, rank[b.depth]! >= rank[m.depth]!, m.targeted.every(c => b.targeted.includes(c))]).toEqual([move, true, true, true]);
+ const readers = (r: Row) => new Map(r.dispatches.flatMap(d => d.role === 'specialist' ? d.checklists.map(c => [c === 'red-team' ? 'red-team' : `checklist:${c}`, d.effort] as const) : [[d.role, d.effort] as const]));
+ const mr = readers(m), br = readers(b);
+ for (const [reader, e] of mr) {
+ expect([move, reader, br.has(reader)]).toEqual([move, reader, true]);
+ if (effort[br.get(reader)!]! >= effort[e]!) continue;
+ expect([reader.startsWith('checklist:'), m.depth, e, br.get(reader), mr.get('red-team'), br.get('red-team')]).toEqual([true, 'light', 'full', ROLE_EFFORT.specialist, 'full', 'full']);
+ split++;
+ }
+ });
+ expect([main.length, split, moves]).toEqual([3168, 252, {
+ 'token-gd: gate/full -> code/light': 288, 'tokens-css: gate/full -> code/light': 288, 'token-ts: gate/full -> gate/full': 288, 'token-secret: gate/full -> gate/full': 288,
+ 'pem: code/light -> gate/full': 288, 'dotenv: code/light -> gate/full': 288, 'id-rsa: code/light -> gate/full': 288, 'secrets-dir: gate/full -> gate/full': 288, 'credentials-json: gate/full -> gate/full': 288,
+ 'token-json: gate/full -> gate/full': 288, 'tokens-db: gate/full -> gate/full': 288,
+ }]);
+ });
+});