mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-26 18:04:31 +01:00
review: Step 11 fixes: results scripts keep secret, spend-cap and paid-call checks; platform depth needs a docs or tests class and the newest bot review; verify re-hashes the outside voice's diff file
Repins lib/review-depth.ts and lib/review-risk.ts under GSTA-258-C: the planner
over the same 200 main commits to 6f1dfd5b7c still plans 196 identically and the
other 4 only raise (handoffs/GSTA-258/C-planner-noloss/plan-c200-final.tsv).
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
686548547a
commit
6e7fc84e75
10 files changed
+62
-19
No files matched your search
@@ -1,7 +1,10 @@
|
||||
import { describe, test, expect } from 'bun:test';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { classifyDiff, nextStep, planReview, scanNumbers, type PlanInput, type ReviewShape } from '../lib/review-depth';
|
||||
import { classifyDiff, nextStep, planReview, platformFits, scanNumbers, type PlanInput, type ReviewShape } from '../lib/review-depth';
|
||||
import { appendEvent, verify } from '../lib/review-ledger';
|
||||
import * as os from 'node:os';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { matchRisk } from '../lib/review-risk';
|
||||
import { renderBrief, sectionTexts, sliceDiff, sliceNote } from '../lib/review-brief';
|
||||
import { validatePolicy, DEFAULT_POLICY, REVIEW_POLICY_KEY_VERSION } from '../lib/ship-policy';
|
||||
@@ -40,6 +43,16 @@ describe('HARN-1 false triggers (harness-evals#231 on 1.93.7.0): data, config an
|
||||
expect(matchRisk({ codePaths: [p], added: { [p]: ["rows = [json.loads(l) for l in open(os.path.join(sys.argv[1], 'trials.jsonl'))]"] }, scopeAuth: false }).size).toBe(0);
|
||||
expect(matchRisk({ codePaths: ['tools/fetch.py'], added: { 'tools/fetch.py': ['p = os.path.join(sys.argv[1], name)'] }, scopeAuth: false }).has('security')).toBe(true);
|
||||
});
|
||||
test('a paid-provider call, a spend cap or a key in a results script or config file still counts', () => {
|
||||
const run = 'benchmarks/run_models.py', sweep = 'analysis/sweep.py', cfg = 'evals/config.yaml';
|
||||
expect(matchRisk({ codePaths: [run], added: { [run]: ['resp = client.messages.create(model=m)'] }, scopeAuth: false }).has('money')).toBe(true);
|
||||
expect(matchRisk({ codePaths: [sweep], added: { [sweep]: ['MAX = spend_cap(5)'] }, scopeAuth: false }).has('money')).toBe(true);
|
||||
expect(matchRisk({ codePaths: [run], added: { [run]: ['key = os.environ["OPENAI_API_KEY"]'] }, scopeAuth: false }).has('secret')).toBe(true);
|
||||
expect(matchRisk({ codePaths: [cfg], added: { [cfg]: ['spend_cap: 9999'] }, scopeAuth: false }).has('money')).toBe(true);
|
||||
expect(matchRisk({ codePaths: [cfg], added: { [cfg]: ['lease_usd: 3'] }, scopeAuth: false }).has('money')).toBe(false);
|
||||
expect(matchRisk({ codePaths: ['lib/analysis/billing.py'], added: { 'lib/analysis/billing.py': ['charge(customer, amount_usd)'] }, scopeAuth: false }).has('money')).toBe(true);
|
||||
expect(matchRisk({ codePaths: ['docs/conf.py'], added: { 'docs/conf.py': ['p = os.path.join(sys.argv[1], name)'] }, scopeAuth: false }).has('security')).toBe(true);
|
||||
});
|
||||
test('a secret in a config file still counts', () => {
|
||||
expect(matchRisk({ codePaths: ['deploy/app.yaml'], added: { 'deploy/app.yaml': [' key: ${OPENAI_API_KEY}'] }, scopeAuth: false }).has('secret')).toBe(true);
|
||||
});
|
||||
@@ -117,6 +130,24 @@ describe('R65 lean dispatch (GSTA-258 build C): one reviewer, once', () => {
|
||||
});
|
||||
|
||||
describe('C6 platform depth (FOUN-32, founderstar#496): a planned skip needs the platform review at the exact head', () => {
|
||||
test('runtime code never fits the platform depth, even with no runtime lines (a registered generated output, a mode-only change)', () => {
|
||||
const none = scanNumbers({});
|
||||
expect(platformFits('code', ['dist/app.js'], 0, none)).toBe(false);
|
||||
expect(platformFits('gate', ['scripts/start.sh'], 0, none)).toBe(false);
|
||||
expect(platformFits('docs', ['docs/a.md'], 0, none)).toBe(true);
|
||||
expect(platformFits('tests', ['test/a.test.ts'], 0, none)).toBe(true);
|
||||
});
|
||||
test('verify marks an outside-voice diff file changed after render as a mismatch', () => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'payload-'));
|
||||
const ledger = path.join(dir, 'ledger.jsonl'), brief = path.join(dir, 'brief.md'), diff = path.join(dir, 'outside-voice.diff');
|
||||
fs.writeFileSync(brief, 'brief'); fs.writeFileSync(diff, '+code\n');
|
||||
const sha = (s: string) => createHash('sha256').update(s).digest('hex');
|
||||
appendEvent(ledger, { event: 'rendered', reader: 'outside-voice', role: 'outside-voice', file: brief, sha256: sha('brief'), payload: { file: diff, sha256: sha('+code\n') } } as any);
|
||||
expect(verify(ledger).rows.find(r => r.kind === 'BRIEF')!.detail).not.toContain('payload_changed_since_render');
|
||||
fs.writeFileSync(diff, '+docs only\n');
|
||||
const row = verify(ledger).rows.find(r => r.kind === 'BRIEF')!;
|
||||
expect([row.status, row.detail.includes('payload_changed_since_render')]).toEqual(['MISMATCH', true]);
|
||||
});
|
||||
const on = (review: ReviewShape['platformReview']) => lean({ platform: 'on', platformReview: review });
|
||||
const docs = { paths: ['docs/howto-install.md', 'test/a.test.ts'] };
|
||||
test('platform on with the review at HEAD on a docs or tests diff: no reader, a planned SKIP for every reader, the core read included', () => {
|
||||
|
||||
@@ -95,8 +95,8 @@ const REVIEWER_BRIEFS: Record<string, { sha: string; replay: Replay }> = {
|
||||
'review/specialists/testing.md': { sha: 'd6cc2bef7be562387d0c0a22fefe646dff9c295f1d34d8453a6cb496584150e4', replay: '#3638' },
|
||||
'review/specialists/targeted.md': { sha: '7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5', replay: 'GST-257' },
|
||||
'scripts/resolvers/fix-check.ts': { sha: '712bf5b0c439e96bac32f19cbe25394dabb4c94aa66600100bfde9b100e15a08', replay: '#3638' },
|
||||
'lib/review-depth.ts': { sha: '7a5ca1f98318902c5ebd3e537f37b7cef05689232ff307a429923397d60abdac', replay: 'GSTA-258-C' },
|
||||
'lib/review-risk.ts': { sha: '2c5b96b921b8be5b977b734b3787361ed80e7d3f779ff6c4a20948f85e4d4474', replay: 'GSTA-258-C' },
|
||||
'lib/review-depth.ts': { sha: 'aec55c5d2f834ad7d25fb0d9f7dba239f45d01361ad3fddc8bf54597d09bdfaa', replay: 'GSTA-258-C' },
|
||||
'lib/review-risk.ts': { sha: '0c840724b6b8f09a3d7daae3eeef15424f2033ed90f4f7890e4a88d248eddb57', replay: 'GSTA-258-C' },
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,6 +74,7 @@ describe('C6 receipt: review_depth platform, honest and bound to the exact head
|
||||
expect(withGh(head, () => platformReceiptDepth(dir, 'main', d, head, '99'), 'APPROVED').ok).toBe(true);
|
||||
expect(withGh(head, () => platformReviewAt(dir, head), 'CHANGES_REQUESTED').ok).toBe(false);
|
||||
expect(withGh(head, () => platformReviewAt(dir, head))).toMatchObject({ ok: true, review: { id: '99' } });
|
||||
expect(withGh(head, () => platformReviewAt(dir, head, { id: '98' })).ok).toBe(false);
|
||||
});
|
||||
test('the receipt records the risk_paths class and the panel mode the base policy gives', () => {
|
||||
const { dir, head } = repo({ review: { risk_paths: ['src/balance/**'] } }, { 'src/balance/x.ts': 'export const x = 1;\n' });
|
||||
|
||||
Reference in new issue
Block a user