leerness 1.9.384 → 1.9.386
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +5 -5
- package/bin/harness.js +24 -34
- package/lib/pure-utils.js +49 -1
- package/package.json +1 -1
- package/scripts/e2e.js +60 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.386 — 2026-06-06 — 5번째 외부평가: secret scan env-family 포함 + gitignore git-일치 (UR-0087)
|
|
4
|
+
|
|
5
|
+
**🔐 `.env.bad` / `.env.local` / `.env.production` 등 env-variant 파일의 시크릿을 스캔 — 통째 스킵되던 보안 false-negative 해소 + gitignore 강등을 git 실제 동작에 맞춤.**
|
|
6
|
+
|
|
7
|
+
### 배경 (5번째 외부평가, GPT-5.5 web · "참고하되 맹신 X")
|
|
8
|
+
"secret scan 이 `.env.bad` 의 OpenAI-key-like 문자열을 놓쳤다." 자체 재현으로 **두 겹의 원인** 발견:
|
|
9
|
+
1. **스캔 제외(주원인)**: `.env.bad` 의 extname 은 `.bad`(.env.local→`.local`, .env.production→`.production`) 라 `SCAN_TEXT_EXT` 에 없어 **파일 자체가 스킵**. bare `.env`(extname `''`)만 스캔되고 있었음.
|
|
10
|
+
2. **과잉 강등**: 1.9.365(CV-6) 의 `.env` 관행 휴리스틱이 `.gitignore` 에 `.env` 만 있어도 모든 `.env.*` 를 보호(info 강등)로 처리 — 그러나 `git check-ignore .env.bad`(gitignore=`.env`) 는 **미무시(커밋 대상)**.
|
|
11
|
+
|
|
12
|
+
### 구현
|
|
13
|
+
1. **env-family 스캔 포함**: extname 대신 basename `/^\.env(\.|$)/` 매칭 → `.env` / `.env.local` / `.env.bad` / `.env.production` 모두 스캔.
|
|
14
|
+
2. **`_gitignoreMatch` + `_globToRe` 순수 추출**(lib/pure-utils.js, UR-0025): 정확매칭 / glob(`*`→`[^/]*`) / dir(`/`) 지원. 1.9.365 과잉 휴리스틱 제거 → **git 실제 동작 일치**: bare `.env` 는 `.env` 만 보호, `.env.bad` 는 커밋 대상(실패). `.env.*` / `.env*` 명시 시에만 `.env.bad` 보호.
|
|
15
|
+
|
|
16
|
+
### 검증 (회귀 0)
|
|
17
|
+
- **selftest 131→132 PASS** (`_gitignoreMatch` 15종 매트릭스 핵심 `.env↛.env.bad`=false + env-family 스캔 와이어 + reference-equality).
|
|
18
|
+
- **E2E 330→331 PASS** (① `.env.bad`+gitignore=`.env`→커밋대상 exit1 + ② `.env`→강등 exit0(CV-6 보존) + ③ `.env.bad`+gitignore=`.env.*`→glob 강등 exit0).
|
|
19
|
+
- 실측 15/15 gitignore 매칭(git 일치) + `git check-ignore` 교차확인.
|
|
20
|
+
|
|
21
|
+
## 1.9.385 — 2026-06-06 — 5번째 외부평가: contract verify markdown bullet 함수 파서 (UR-0086)
|
|
22
|
+
|
|
23
|
+
**📐 `contract verify` spec 파서가 markdown bullet `- name(args)` 함수 선언을 감지 — 실제 누락을 통과시키던 false-negative 해소.**
|
|
24
|
+
|
|
25
|
+
### 배경 (5번째 외부평가, GPT-5.5 web · "참고하되 맹신 X")
|
|
26
|
+
spec 파서가 `function name(...)` 와 backtick `` `name(` `` 만 추출하고 markdown bullet 목록(`- add(a,b)`)은 미감지. 자체 재현: bullet 3개 spec + impl 1개 export → `specFunctions: []`, `missingFunctions: []`, `ok: true`(실제론 2개 누락). **재현 후 수정**.
|
|
27
|
+
|
|
28
|
+
### 구현
|
|
29
|
+
1. **`_parseContractSpec(specText)` 순수 추출**(lib/pure-utils.js, UR-0025): `{ declared, mentioned, fields }`.
|
|
30
|
+
- **declared**(강선언, 누락검사 대상): `function name(` + markdown bullet `- name(args)` / `* ` / `1. `.
|
|
31
|
+
- **mentioned**(약언급, 표시만): backtick `` `name(` `` — 산문 인라인 언급 오탐 방지 위해 관대(기존 동작 유지).
|
|
32
|
+
2. **bullet 패턴**: `^\s*(?:[-*+]|\d+\.)\s+name(` — name 직후 `(`(공백 불허) + ASCII 식별자만 → 산문 `- 합계 (a+b)` / `- foo: bar(x)` / `**bold**` 오탐 0.
|
|
33
|
+
3. **missing-검출 잠재 FN 수정**: 기존 `specText.includes('function '+fn)` 가드가 bullet/backtick 추출명을 무력화 → `declaredSpec` 기준으로 교체(bullet 함수도 누락 감지, backtick 관대 유지).
|
|
34
|
+
|
|
35
|
+
### 검증 (회귀 0)
|
|
36
|
+
- **selftest 130→131 PASS** (bullet/asterisk/numbered 감지 + reference-equality + 산문 FP 0 + 인라인 제거 확인).
|
|
37
|
+
- **E2E 329→330 PASS** (bullet spec 3함수 감지 + subtract/multiply 누락 + add 보존 + backtick 관대 + 산문 FP 0).
|
|
38
|
+
- 실측 8/8 FP/감지 케이스 + 기존 B(1.9.35) `function bar`/`isCritical` 무회귀.
|
|
39
|
+
|
|
3
40
|
## 1.9.384 — 2026-06-06 — 5번째 외부평가: status/verify --json 구조화 출력 일관성 (UR-0085)
|
|
4
41
|
|
|
5
42
|
**🔌 `status --json` / `verify --json` 이 사람용 텍스트 → 구조화 JSON — AI 에이전트 자동화용 출력 일관성 확보.**
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **AI 코딩 에이전트의 거짓 완료·중복·망각·충돌을 막아주는 검수·기억·협업 CLI 하네스.**
|
|
4
4
|
> **A CLI harness that stops AI coding agents from faking completion, duplicating work, forgetting context, and colliding.**
|
|
5
5
|
|
|
6
|
-
[](https://www.npmjs.com/package/leerness) [](https://www.npmjs.com/package/leerness) []() []() []() []() []() []()
|
|
7
7
|
|
|
8
8
|
```
|
|
9
9
|
╔══════════════════════════════════════════════════════════════╗
|
|
@@ -471,7 +471,7 @@ MIT — © leerness contributors
|
|
|
471
471
|
<!-- leerness:project-readme:start -->
|
|
472
472
|
## Leerness Project Harness
|
|
473
473
|
|
|
474
|
-
이 프로젝트는 Leerness v1.9.
|
|
474
|
+
이 프로젝트는 Leerness v1.9.386 하네스를 사용합니다. AI 에이전트는 작업 전 `leerness handoff`로 컨텍스트를 적재하고, 작업 후 `leerness check`/`leerness audit`/`leerness session close`를 수행해야 합니다.
|
|
475
475
|
|
|
476
476
|
### 정체성 — AI 에이전트 운영 레이어 (UR-0030)
|
|
477
477
|
|
|
@@ -525,7 +525,7 @@ leerness memory restore decision <date|title>
|
|
|
525
525
|
|
|
526
526
|
### MCP server (외부 AI 통합)
|
|
527
527
|
|
|
528
|
-
Leerness v1.9.
|
|
528
|
+
Leerness v1.9.386는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **85개 도구**를 노출:
|
|
529
529
|
|
|
530
530
|
```jsonc
|
|
531
531
|
// 카테고리별
|
|
@@ -546,7 +546,7 @@ Leerness v1.9.384는 stdio JSON-RPC MCP server를 내장합니다 — Claude Cod
|
|
|
546
546
|
`<<autonomous-loop-dynamic>>` 신호만 보내면 AI가:
|
|
547
547
|
1) 다음 라운드 후보 선정 → 2) 코드 변경 → 3) stress-v* 신규 작성 + 누적 회귀 → 4) e2e 219/219 → 5) npm pack + git tag + GitHub release → 6) main 자동 push (1.9.140+) → 7) session close → 8) 다음 라운드 예약.
|
|
548
548
|
|
|
549
|
-
현재 누적: **70 라운드 (1.9.40 → 1.9.
|
|
549
|
+
현재 누적: **70 라운드 (1.9.40 → 1.9.386)** · 매 라운드 GitHub release/태그 생성 · _reports/는 비공개 보존.
|
|
550
550
|
|
|
551
551
|
### 성능 가이드 (1.9.140 측정)
|
|
552
552
|
|
|
@@ -584,6 +584,6 @@ leerness release pack --close --auto-main-push
|
|
|
584
584
|
- `.harness/session-handoff.md`: 다음 세션 인수인계 (자동 작성)
|
|
585
585
|
- `.harness/lessons.md` / `decisions.md` / `rules.md`: 영구 메모리 (5 surface)
|
|
586
586
|
|
|
587
|
-
Last synced by Leerness v1.9.
|
|
587
|
+
Last synced by Leerness v1.9.386: 2026-06-06
|
|
588
588
|
<!-- leerness:project-readme:end -->
|
|
589
589
|
|
package/bin/harness.js
CHANGED
|
@@ -23,13 +23,13 @@ const { _isSecretKey, _isPlaceholderSecret, _looksSecretLike, _mergeLines, _merg
|
|
|
23
23
|
_personaSummaries, _translate,
|
|
24
24
|
_decisionsFromMd, _renderDecisionsMd, _renderLessonsMd,
|
|
25
25
|
_withBuiltinSource, _esc, _roadmapTokenStyles, _parseSkillMd,
|
|
26
|
-
_migrationGuideText } = require('../lib/pure-utils'); // 1.9.318~
|
|
26
|
+
_migrationGuideText, _parseContractSpec, _gitignoreMatch } = require('../lib/pure-utils'); // 1.9.318~386 (UR-0025/0053/0075/0086/0087): 순수 유틸 모듈 분리
|
|
27
27
|
// 1.9.304 (UR-0025): 순수 분석/검증 함수 모듈 분리.
|
|
28
28
|
const { _evidenceQuality, _parseEvidenceStats, _shellGuardAnalyze, _claimFileInGit, _epistemicHonestyCheck } = require('../lib/analyzers');
|
|
29
29
|
// 1.9.295 (UR-0025 4단계): 정적 데이터 카탈로그 모듈 분리 (비파괴, require-based).
|
|
30
30
|
const { CAPABILITY_SURFACE, POWERFUL_COMMANDS, ADAPTERS, REUSE_CATEGORIES, REUSE_CHECKLIST, _DEFAULT_PLATFORM_CONSTRAINTS, _DEFAULT_DOMAIN_CATALOG, _LSP_LANG_PATTERNS, OPTIMISM_PATTERNS, BUILT_IN_PERSONAS, STRINGS, BUILTIN_CATALOG, ROADMAP_STATUS_LABEL, ROADMAP_STATUS_COLOR, SECRET_PATTERNS, MERGE_OVERWRITE_FILES, MINIMAL_SKIP_KEYS, REQUIRED_WORKSPACE_FILES, KEYWORD_STOPWORDS, SKILL_CATALOG_PRESETS } = require('../lib/catalogs'); // 1.9.344/368/369 (UR-0025): catalog 분리 (MERGE_OVERWRITE_FILES/MINIMAL_SKIP_KEYS 포함)
|
|
31
31
|
|
|
32
|
-
const VERSION = '1.9.
|
|
32
|
+
const VERSION = '1.9.386';
|
|
33
33
|
|
|
34
34
|
// 1.9.290 (UR-0037, Codex gpt-5.5 #4 수렴): CLI 전용 부작용은 require 시 실행하지 않는다.
|
|
35
35
|
// 이전: warning listener 제거 / NODE_OPTIONS 변경 / chcp IIFE 가 top-level 즉시 실행 → require('harness') 시 호스트 프로세스 오염.
|
|
@@ -2987,6 +2987,8 @@ function _selfTestCases() {
|
|
|
2987
2987
|
{ name: 'UR-0025 큰핸들러토대: lib/io.js 프리미티브(log/ok/warn/fail/today/now) 모듈 분리 + 동작 (1.9.382)', run: () => { const io = require('../lib/io'); const exportsOk = ['log', 'ok', 'warn', 'fail', 'today', 'now'].every(k => typeof io[k] === 'function') && io.log === log && io.fail === fail && io.now === now; const todayOk = /^\d{4}-\d{2}-\d{2}$/.test(io.today()) && /^\d{4}-\d{2}-\d{2}T/.test(io.now()); const src = read(__filename); const moved = src.includes("require('../lib/io')") && !/^function fail\(s\) \{ log/m.test(src) && !/^function now\(\) \{ return new Date/m.test(src); let exitOk = false; const saved = process.exitCode; const _w = process.stdout.write; try { process.stdout.write = () => true; process.exitCode = 0; io.fail('probe'); exitOk = process.exitCode === 1; } finally { process.stdout.write = _w; process.exitCode = saved; } return exportsOk && todayOk && moved && exitOk; } },
|
|
2988
2988
|
{ name: 'UR-0025 큰핸들러토대: lib/io.js fs 프리미티브(read/writeUtf8/exists/mkdirp/append/rel/absRoot) 분리 + round-trip (1.9.383)', run: () => { const io = require('../lib/io'); const exp = ['absRoot', 'exists', 'read', 'readBuf', 'mkdirp', 'writeUtf8', 'append', 'rel'].every(k => typeof io[k] === 'function') && io.read === read && io.writeUtf8 === writeUtf8 && io.exists === exists; const src = read(__filename); const moved = !/^function writeUtf8\(p, s\) \{/m.test(src) && !/^function read\(p\) \{/m.test(src) && !/^function exists\(p\) \{/m.test(src); const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_io_')); let rt = false; try { const f = path.join(tmp, 'a', 'b.txt'); io.writeUtf8(f, '한글RT'); rt = io.exists(f) && io.read(f) === '한글RT' && io.rel(tmp, f) === 'a/b.txt'; } finally { try { fs.rmSync(tmp, { recursive: true, force: true }); } catch {} } return exp && moved && rt; } },
|
|
2989
2989
|
{ name: '5th외부평가/UR-0085: status --json 구조화 출력 + verify --json 와이어 (1.9.384)', run: () => { if (typeof status !== 'function' || typeof verify !== 'function') return false; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_sj_')); const save = process.argv; const _w = process.stdout.write; let so = ''; try { fs.mkdirSync(path.join(tmp, '.harness'), { recursive: true }); process.argv = ['node', 'h', 'status', tmp, '--json']; process.stdout.write = s => { so += s; return true; }; status(tmp); } catch {} finally { process.stdout.write = _w; process.argv = save; try { fs.rmSync(tmp, { recursive: true, force: true }); } catch {} } let sj; try { sj = JSON.parse(so); } catch {} const statusOk = !!sj && typeof sj.total === 'number' && typeof sj.present === 'number' && 'healthy' in sj && Array.isArray(sj.missing); const src = read(__filename); const verifyWired = /function verify\(root\) \{[\s\S]*?has\('--json'\)[\s\S]*?JSON\.stringify\(\{ ok:/.test(src); return statusOk && verifyWired; } },
|
|
2990
|
+
{ name: '5th외부평가/UR-0086: _parseContractSpec markdown bullet 함수 감지 + 순수 추출 (1.9.385)', run: () => { const m = require('../lib/pure-utils'); if (m._parseContractSpec !== _parseContractSpec) return false; const p = _parseContractSpec('# Spec\n- add(a,b)\n* subtract(a,b)\n1. multiply(a,b)\nfunction legacy(x)\n`mentioned(`\ntick.amount\n'); const declOk = ['add', 'subtract', 'multiply', 'legacy'].every(n => p.declared.includes(n)) && p.declared.length === 4; const menOk = p.mentioned.includes('mentioned') && !p.declared.includes('mentioned'); const fieldOk = p.fields.includes('amount'); const fpOk = _parseContractSpec('- 합계 (a+b)\n- result (total)\n- foo: bar(x)\n**bold**').declared.length === 0; const src = read(__filename); const moved = src.includes('_parseContractSpec(specText)') && !/specText\.matchAll\(\/function/.test(src); return declOk && menOk && fieldOk && fpOk && moved; } },
|
|
2991
|
+
{ name: '5th외부평가/UR-0087: _gitignoreMatch git 일치(.env↛.env.bad) + env-family 스캔 (1.9.386)', run: () => { const m = require('../lib/pure-utils'); if (m._gitignoreMatch !== _gitignoreMatch) return false; const gm = _gitignoreMatch; const semOk = gm('.env', '.env') === true && gm('.env', '.env.bad') === false && gm('.env', '.env.local') === false && gm('.env.*', '.env.bad') === true && gm('.env*', '.env') === true && gm('*.pem', 'k.pem') === true && gm('src/', 'src/a.txt') === true; const src = read(__filename); const envFamilyScan = src.includes('const isEnvFamily =') && src.includes('!SCAN_TEXT_EXT.has(ext) && !isEnvFamily'); const delegated = src.includes('return _gitignoreMatch(gi, fileRel)'); return semOk && envFamilyScan && delegated; } },
|
|
2990
2992
|
{ name: 'VERSION 형식 (x.y.z)', run: () => /^\d+\.\d+\.\d+$/.test(VERSION) }
|
|
2991
2993
|
];
|
|
2992
2994
|
}
|
|
@@ -7256,23 +7258,13 @@ function* walk(root, base = root, depth = 0, extras = null) {
|
|
|
7256
7258
|
else yield p;
|
|
7257
7259
|
}
|
|
7258
7260
|
}
|
|
7259
|
-
// 1.9.365 (외부리뷰 CV-6/UR-0081): 간이 .gitignore 매칭 — gitignored
|
|
7260
|
-
//
|
|
7261
|
+
// 1.9.365 (외부리뷰 CV-6/UR-0081): 간이 .gitignore 매칭 — gitignored 파일의 시크릿은 커밋 제외(설계상 안전) → 실패 대신 info.
|
|
7262
|
+
// 1.9.386 (UR-0087, 5번째 외부평가): 순수 _gitignoreMatch 로 위임 + bare '.env' → 모든 '.env.*' 과잉보호 제거.
|
|
7263
|
+
// git 실제 동작 일치: '.env' 는 '.env' 만 보호, '.env.bad' 는 커밋 대상(실패). '.env.*'/'.env*' 명시 시에만 보호.
|
|
7261
7264
|
function _isLikelyGitignored(root, fileRel) {
|
|
7262
7265
|
let gi;
|
|
7263
7266
|
try { gi = read(path.join(root, '.gitignore')); } catch { return false; }
|
|
7264
|
-
|
|
7265
|
-
const base = relPosix.split('/').pop();
|
|
7266
|
-
for (let pat of gi.split(/\r?\n/)) {
|
|
7267
|
-
pat = pat.trim();
|
|
7268
|
-
if (!pat || pat.startsWith('#') || pat.startsWith('!')) continue;
|
|
7269
|
-
const p = pat.replace(/^\/+|\/+$/g, '');
|
|
7270
|
-
if (p === relPosix || p === base) return true;
|
|
7271
|
-
if (pat === '.env' && /^\.env(\.|$)/.test(base)) return true; // .env 관행상 .env.* 도 보호
|
|
7272
|
-
if (p.startsWith('*.') && base.endsWith(p.slice(1))) return true;
|
|
7273
|
-
if (pat.endsWith('/') && (relPosix === p || relPosix.startsWith(p + '/'))) return true;
|
|
7274
|
-
}
|
|
7275
|
-
return false;
|
|
7267
|
+
return _gitignoreMatch(gi, fileRel);
|
|
7276
7268
|
}
|
|
7277
7269
|
function scanSecrets(root) {
|
|
7278
7270
|
root = absRoot(root);
|
|
@@ -7282,7 +7274,10 @@ function scanSecrets(root) {
|
|
|
7282
7274
|
try { _iter = fs.statSync(root).isFile() ? [root] : walk(root); } catch { _iter = walk(root); }
|
|
7283
7275
|
for (const file of _iter) {
|
|
7284
7276
|
const ext = path.extname(file).toLowerCase();
|
|
7285
|
-
|
|
7277
|
+
// 1.9.386 (UR-0087, 5번째 외부평가): env-family(.env / .env.local / .env.bad / .env.production …)는
|
|
7278
|
+
// extname 이 .bad/.local/.production 라 SCAN_TEXT_EXT 에 없어 통째로 스킵되던 FN → basename 으로 강제 포함.
|
|
7279
|
+
const isEnvFamily = /^\.env(\.|$)/.test(path.basename(file));
|
|
7280
|
+
if (!SCAN_TEXT_EXT.has(ext) && !isEnvFamily) continue;
|
|
7286
7281
|
let text;
|
|
7287
7282
|
try { text = read(file); } catch { continue; }
|
|
7288
7283
|
if (text.length > 1024 * 1024) continue;
|
|
@@ -20165,18 +20160,13 @@ function contractVerifyCmd(specPath, implPath) {
|
|
|
20165
20160
|
if (!exists(specFile)) { fail(`spec 파일 없음: ${specFile}`); return process.exit(1); }
|
|
20166
20161
|
if (!exists(implFile)) { fail(`impl 파일 없음: ${implFile}`); return process.exit(1); }
|
|
20167
20162
|
const specText = read(specFile);
|
|
20168
|
-
// spec
|
|
20169
|
-
//
|
|
20170
|
-
//
|
|
20171
|
-
|
|
20172
|
-
const
|
|
20173
|
-
const
|
|
20174
|
-
|
|
20175
|
-
for (const m of specText.matchAll(/function\s+([A-Za-z_$][\w$]*)\s*\(/g)) fnSpec.add(m[1]);
|
|
20176
|
-
// backtick에 싸인 함수 호출 같은 형태: `xxx(`
|
|
20177
|
-
for (const m of specText.matchAll(/`([A-Za-z_$][\w$]*)\s*\(/g)) fnSpec.add(m[1]);
|
|
20178
|
-
// 필드: tick.<name>
|
|
20179
|
-
for (const m of specText.matchAll(/tick\.([A-Za-z_$][\w$]*)/g)) fieldSpec.add(m[1]);
|
|
20163
|
+
// 1.9.385 (UR-0086, 5th외부평가): spec 함수/필드 추출을 순수 파서 _parseContractSpec 로 위임.
|
|
20164
|
+
// declared(강선언): function 시그니처 + markdown bullet "- name(args)" — 누락검사 대상.
|
|
20165
|
+
// mentioned(약언급): backtick `name(` — 표시만(기존 관대성 유지, 산문 인라인 언급 오탐 방지).
|
|
20166
|
+
const parsedSpec = _parseContractSpec(specText);
|
|
20167
|
+
const declaredSpec = new Set(parsedSpec.declared);
|
|
20168
|
+
const fnSpec = new Set([...parsedSpec.declared, ...parsedSpec.mentioned]); // 표시용 전체
|
|
20169
|
+
const fieldSpec = new Set(parsedSpec.fields);
|
|
20180
20170
|
// 1.9.36 BUG-fix: require()는 side-effect 실행 위험 (CLI 스크립트는 require로 실행됨).
|
|
20181
20171
|
// 대신 정적 소스 분석 — module.exports = { foo, bar } / exports.foo = ... / module.exports.foo = ... 패턴 grep.
|
|
20182
20172
|
const implSrc = read(implFile);
|
|
@@ -20191,12 +20181,12 @@ function contractVerifyCmd(specPath, implPath) {
|
|
|
20191
20181
|
// pattern 2: exports.foo = / module.exports.foo =
|
|
20192
20182
|
for (const m of implSrc.matchAll(/(?:module\.)?exports\.([A-Za-z_$][\w$]*)\s*=/g)) implExports.add(m[1]);
|
|
20193
20183
|
// pattern 3: function foo + module.exports에 포함되었는지는 위에서 처리됨
|
|
20194
|
-
// 검사: spec
|
|
20184
|
+
// 검사: spec 강선언(function 시그니처 + markdown bullet) 함수 중 impl exports에 없는 것.
|
|
20185
|
+
// 1.9.385 (UR-0086): 기존 `specText.includes('function '+fn)` 가드는 bullet/backtick 추출명을 무력화하던 잠재 FN.
|
|
20186
|
+
// → declaredSpec(강선언) 기준으로 교체: bullet 함수도 누락 감지, backtick 약언급은 관대(검사 제외) 유지.
|
|
20195
20187
|
const missing = [];
|
|
20196
|
-
for (const fn of
|
|
20197
|
-
if (implExports.has(fn))
|
|
20198
|
-
// spec에 'function fnName('이 있지만 impl exports에 없으면 미구현
|
|
20199
|
-
if (specText.includes(`function ${fn}`) && !implExports.has(fn)) missing.push(fn);
|
|
20188
|
+
for (const fn of declaredSpec) {
|
|
20189
|
+
if (!implExports.has(fn)) missing.push(fn);
|
|
20200
20190
|
}
|
|
20201
20191
|
const fieldMissing = [];
|
|
20202
20192
|
for (const f of fieldSpec) {
|
package/lib/pure-utils.js
CHANGED
|
@@ -925,7 +925,11 @@ module.exports = {
|
|
|
925
925
|
// 1.9.339 (UR-0053): decisions canonical 파서/렌더 (JSON canonical, MD projection)
|
|
926
926
|
_parseDecisionBlock, _decisionsFromMd, _renderDecisionsMd,
|
|
927
927
|
// 1.9.355 (UR-0075 Phase A): 크로스버전 마이그레이션 가이드
|
|
928
|
-
_migrationGuideText
|
|
928
|
+
_migrationGuideText,
|
|
929
|
+
// 1.9.385 (UR-0086, 5th외부평가): contract spec 순수 파서 (markdown bullet 함수 선언 감지)
|
|
930
|
+
_parseContractSpec,
|
|
931
|
+
// 1.9.386 (UR-0087, 5th외부평가): 간이 .gitignore 매칭 + glob (bare .env → .env.* 과잉보호 제거)
|
|
932
|
+
_gitignoreMatch, _globToRe
|
|
929
933
|
};
|
|
930
934
|
|
|
931
935
|
// 1.9.355 (UR-0075 Phase A): AI 에이전트용 크로스버전 마이그레이션 안전 워크플로 가이드 (순수 텍스트). 임시설치 + --path + 백업 + diff 검증.
|
|
@@ -968,3 +972,47 @@ function _migrationGuideText(version) {
|
|
|
968
972
|
];
|
|
969
973
|
return L.join('\n');
|
|
970
974
|
}
|
|
975
|
+
|
|
976
|
+
// 1.9.385 (UR-0086, 5번째 외부평가): contract spec 함수/필드 추출 — 순수 파서.
|
|
977
|
+
// declared(강선언, 검사 대상): "function name(" + markdown bullet "- name(args)" / "* " / "1. ".
|
|
978
|
+
// mentioned(약언급, 표시만): backtick `name(` — 산문 인라인 언급일 수 있어 누락검사 제외(기존 관대성 유지).
|
|
979
|
+
// fields: tick.name. bullet 패턴은 name 직후 '(' (공백 불허) → 산문 "- 합 (a+b)" 오탐 방지, ASCII 식별자만.
|
|
980
|
+
function _parseContractSpec(specText) {
|
|
981
|
+
const s = specText || '';
|
|
982
|
+
const declared = new Set();
|
|
983
|
+
const mentioned = new Set();
|
|
984
|
+
const fields = new Set();
|
|
985
|
+
for (const m of s.matchAll(/function\s+([A-Za-z_$][\w$]*)\s*\(/g)) declared.add(m[1]);
|
|
986
|
+
for (const m of s.matchAll(/^\s*(?:[-*+]|\d+\.)\s+([A-Za-z_$][\w$]*)\(/gm)) declared.add(m[1]);
|
|
987
|
+
for (const m of s.matchAll(/`([A-Za-z_$][\w$]*)\s*\(/g)) mentioned.add(m[1]);
|
|
988
|
+
for (const m of s.matchAll(/tick\.([A-Za-z_$][\w$]*)/g)) fields.add(m[1]);
|
|
989
|
+
return { declared: [...declared], mentioned: [...mentioned], fields: [...fields] };
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
// 1.9.386 (UR-0087, 5번째 외부평가): 간이 glob → 정규식. '*' → [^/]* (경로구분 제외), 나머지는 리터럴.
|
|
993
|
+
function _globToRe(glob) {
|
|
994
|
+
const esc = String(glob).replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '[^/]*');
|
|
995
|
+
return new RegExp('^' + esc + '$');
|
|
996
|
+
}
|
|
997
|
+
// 1.9.386 (UR-0087, 5번째 외부평가): 간이 .gitignore 매칭 (순수). full semantics 아님 — 정확매칭 / glob(*) / dir(/) 지원.
|
|
998
|
+
// 1.9.365 의 과잉 휴리스틱(bare '.env' → 모든 '.env.*' 보호) 제거 → git 실제 동작과 일치:
|
|
999
|
+
// '.env' 는 '.env' 만 매칭(.env.bad 미보호 = 커밋 대상). '.env.*' / '.env*' 같은 명시 glob 만 .env.bad 보호.
|
|
1000
|
+
function _gitignoreMatch(giText, fileRel) {
|
|
1001
|
+
if (!giText) return false;
|
|
1002
|
+
const relPosix = String(fileRel).replace(/\\/g, '/');
|
|
1003
|
+
const base = relPosix.split('/').pop();
|
|
1004
|
+
for (let pat of String(giText).split(/\r?\n/)) {
|
|
1005
|
+
pat = pat.trim();
|
|
1006
|
+
if (!pat || pat.startsWith('#') || pat.startsWith('!')) continue;
|
|
1007
|
+
const isDir = pat.endsWith('/');
|
|
1008
|
+
const p = pat.replace(/^\/+|\/+$/g, '');
|
|
1009
|
+
if (!p) continue;
|
|
1010
|
+
if (p === relPosix || p === base) return true; // 정확 매칭 (.env → .env)
|
|
1011
|
+
if (isDir && (relPosix === p || relPosix.startsWith(p + '/'))) return true; // dir/
|
|
1012
|
+
if (p.includes('*')) { // glob: *.pem / .env.* / .env*
|
|
1013
|
+
const re = _globToRe(p);
|
|
1014
|
+
if (re.test(p.includes('/') ? relPosix : base)) return true;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
return false;
|
|
1018
|
+
}
|
package/package.json
CHANGED
package/scripts/e2e.js
CHANGED
|
@@ -5366,5 +5366,65 @@ total++;
|
|
|
5366
5366
|
if (!ok) failed++;
|
|
5367
5367
|
}
|
|
5368
5368
|
|
|
5369
|
+
// 1.9.385 회귀 (5번째 외부평가/UR-0086): contract verify spec 파서가 markdown bullet "- name(args)" 함수 선언 감지 + backtick 약언급 관대 유지
|
|
5370
|
+
total++;
|
|
5371
|
+
{
|
|
5372
|
+
let ok = false;
|
|
5373
|
+
try {
|
|
5374
|
+
const d = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-contract-bullet-'));
|
|
5375
|
+
const spec = path.join(d, 'spec.md');
|
|
5376
|
+
const impl = path.join(d, 'impl.js');
|
|
5377
|
+
fs.writeFileSync(spec, '# Calc API\n\n함수 목록:\n- add(a, b): 합\n- subtract(a, b): 차\n- multiply(a, b): 곱\n', 'utf8');
|
|
5378
|
+
fs.writeFileSync(impl, '"use strict";\nfunction add(a,b){return a+b}\nmodule.exports={add};\n', 'utf8');
|
|
5379
|
+
const r = cp.spawnSync(process.execPath, [CLI, 'contract', 'verify', spec, impl, '--json'], { encoding: 'utf8', timeout: 10000 });
|
|
5380
|
+
const j = JSON.parse(r.stdout);
|
|
5381
|
+
const bulletOk = j.specFunctions.includes('add') && j.specFunctions.includes('subtract') && j.specFunctions.includes('multiply') &&
|
|
5382
|
+
j.missingFunctions.includes('subtract') && j.missingFunctions.includes('multiply') && !j.missingFunctions.includes('add') && j.ok === false;
|
|
5383
|
+
// backtick 약언급은 누락검사 제외(관대) + 산문 bullet FP 방지 회귀
|
|
5384
|
+
const spec2 = path.join(d, 'spec2.md');
|
|
5385
|
+
const impl2 = path.join(d, 'impl2.js');
|
|
5386
|
+
fs.writeFileSync(spec2, '# S\n\n`onlyMentioned(` 는 인라인 언급\nfunction realFn(x) {}\n- 합계 (a + b) 계산\n', 'utf8');
|
|
5387
|
+
fs.writeFileSync(impl2, '"use strict";\nfunction realFn(x){return x}\nmodule.exports={realFn};\n', 'utf8');
|
|
5388
|
+
const r2 = cp.spawnSync(process.execPath, [CLI, 'contract', 'verify', spec2, impl2, '--json'], { encoding: 'utf8', timeout: 10000 });
|
|
5389
|
+
const j2 = JSON.parse(r2.stdout);
|
|
5390
|
+
const lenientOk = !j2.missingFunctions.includes('onlyMentioned') && !j2.specFunctions.includes('합계') && j2.ok === true; // mentioned 관대 + 산문 FP 0
|
|
5391
|
+
fs.rmSync(d, { recursive: true, force: true });
|
|
5392
|
+
ok = bulletOk && lenientOk;
|
|
5393
|
+
} catch {}
|
|
5394
|
+
console.log(ok ? '✓ B(1.9.385) 5th외부평가: contract verify markdown bullet 함수 감지 + backtick 관대 + 산문 FP 0 (UR-0086)' : '✗ contract bullet 파서 실패');
|
|
5395
|
+
if (!ok) failed++;
|
|
5396
|
+
}
|
|
5397
|
+
|
|
5398
|
+
// 1.9.386 회귀 (5번째 외부평가/UR-0087): secret scan env-family 포함 + gitignore git-일치 (.env↛.env.bad 미보호=커밋대상)
|
|
5399
|
+
total++;
|
|
5400
|
+
{
|
|
5401
|
+
let ok = false;
|
|
5402
|
+
try {
|
|
5403
|
+
const key = 'OPENAI_API_KEY=sk-proj-abc123def456ghi789jkl012mno345pqr678stuvwx\n';
|
|
5404
|
+
// ① .env.bad(extname .bad, 종전 스킵) + gitignore=.env → 스캔됨 + 커밋대상 실패(exit1). git 실제 동작 일치(핵심 FN fix)
|
|
5405
|
+
const d1 = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-envbad-'));
|
|
5406
|
+
fs.writeFileSync(path.join(d1, '.gitignore'), '.env\n');
|
|
5407
|
+
fs.writeFileSync(path.join(d1, '.env.bad'), key);
|
|
5408
|
+
const r1 = cp.spawnSync(process.execPath, [CLI, 'scan', 'secrets', d1], { encoding: 'utf8', timeout: 20000 });
|
|
5409
|
+
const flaggedOk = r1.status === 1 && /\.env\.bad/.test(r1.stdout || '') && /OpenAI/.test(r1.stdout || '');
|
|
5410
|
+
// ② .env + gitignore=.env → 강등 info(exit0). 기존 CV-6(1.9.365) 보존
|
|
5411
|
+
const d2 = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-envok-'));
|
|
5412
|
+
fs.writeFileSync(path.join(d2, '.gitignore'), '.env\n');
|
|
5413
|
+
fs.writeFileSync(path.join(d2, '.env'), 'TOKEN=npm_abcdefghijklmnopqrstuvwxyz0123456789\n');
|
|
5414
|
+
const r2 = cp.spawnSync(process.execPath, [CLI, 'scan', 'secrets', d2], { encoding: 'utf8', timeout: 20000 });
|
|
5415
|
+
const downgradeOk = r2.status === 0 && /gitignored/.test(r2.stdout || '');
|
|
5416
|
+
// ③ .env.bad + gitignore=.env.* → 명시 glob 보호 → 강등 info(exit0). 적정설정 프로젝트 FP 0
|
|
5417
|
+
const d3 = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-envglob-'));
|
|
5418
|
+
fs.writeFileSync(path.join(d3, '.gitignore'), '.env.*\n');
|
|
5419
|
+
fs.writeFileSync(path.join(d3, '.env.bad'), key);
|
|
5420
|
+
const r3 = cp.spawnSync(process.execPath, [CLI, 'scan', 'secrets', d3], { encoding: 'utf8', timeout: 20000 });
|
|
5421
|
+
const globOk = r3.status === 0 && /gitignored/.test(r3.stdout || '');
|
|
5422
|
+
[d1, d2, d3].forEach(d => fs.rmSync(d, { recursive: true, force: true }));
|
|
5423
|
+
ok = flaggedOk && downgradeOk && globOk;
|
|
5424
|
+
} catch {}
|
|
5425
|
+
console.log(ok ? '✓ B(1.9.386) 5th외부평가: secret scan env-family 포함 + gitignore git-일치(.env↛.env.bad 커밋대상) (UR-0087)' : '✗ secret scan env-family/gitignore 실패');
|
|
5426
|
+
if (!ok) failed++;
|
|
5427
|
+
}
|
|
5428
|
+
|
|
5369
5429
|
console.log(`\nE2E result: ${total - failed}/${total} passed · ${((Date.now() - _e2eStart) / 1000).toFixed(0)}s`);
|
|
5370
5430
|
if (failed > 0) process.exit(1);
|