leerness 1.9.322 → 1.9.324

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 CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.9.324 — 2026-06-05 — UR-0025(증분): 메모리 MD 파서 분리 + _compareSemver 중복 제거
4
+
5
+ **🧩 점진적 비파괴 모듈화 — 순수 메모리 파서 2종을 lib/pure-utils 로 이전 + 중복 버전비교 함수 통합.**
6
+
7
+ ### 구현 (UR-0025)
8
+ 1. **순수 메모리 MD 파서 → `lib/pure-utils.js` 분리**: `_countDatedBlocks`(코드펜스 제거 후 날짜 블록 카운트) + `_extractDecisionBlocks`(결정 블록 추출, Template 제외). decisions/lessons count 의 단일 진실소스. harness.js 인라인 제거 → require.
9
+ 2. **`_compareSemver` 중복 제거**: pure-utils 의 `compareVer` 와 기능 동일(중복) → `compareVer` 단일화(호출 1곳 교체, 함수 삭제).
10
+ 3. selftest 71→72 · e2e 268→269.
11
+ 4. 테스트 견고화: B(1.9.318) HTML 분리 테스트의 import 순서 의존 정규식 → 순서 비의존(이후 import 추가 허용)으로 수정.
12
+
13
+ ### 검증
14
+ - **selftest 72/72 PASS** · **E2E 269/269 PASS** (회귀 0).
15
+ - 실측: 모듈 `_countDatedBlocks`(펜스 템플릿 제외)·`_extractDecisionBlocks` 동작 · harness 인라인/`_compareSemver` 제거 확인 · context decisions count 정상 · 소비 명령 회귀 없음.
16
+ - ⚠️ 첫 e2e 268/269(B(1.9.318) 정규식이 require 라인 변경에 취약) → 정규식 견고화 후 269/269.
17
+
18
+ ## 1.9.323 — 2026-06-05 — UR-0054 ⑥: fresh-init gate 통과 (lazy detect 부재신호 비차단)
19
+
20
+ **🚀 `leerness init` 직후 `leerness gate` 가 빈 트래커/미생성 handoff 때문에 즉시 실패하던 UX 결함 수정.**
21
+
22
+ ### 배경 (UR-0054 ⑥)
23
+ fresh init 후 `gate`(verify+audit+scan+encoding+lazy) 중 **lazy detect 만 exit 1** — `handoff_never_generated`/`handoff_empty`/`no_test_run` 같은 "아직 작업 안 함" 신호를 lazy work 위반처럼 차단. 갓 init 한 프로젝트가 즉시 gate 실패 → 나쁜 첫인상.
24
+
25
+ ### 구현 (UR-0054 ⑥)
26
+ 1. **작업 흔적 기반 차단 판정**: `done/completed/verified` row 가 하나도 없으면(fresh/무작업) "부재" 신호(`progress_empty`/`handoff_never_generated`/`handoff_empty`/`no_test_run`)는 **어드바이저리(비차단)**. `blockingIssues = issues − advisory(무작업 시)`.
27
+ 2. **active 프로젝트 보호 유지**: done-claim 이 있으면 모든 신호가 차단(기존 동작). 특히 `evidence_missing`(증거 없는 done)은 항상 차단.
28
+ 3. JSON 에 `blockingIssues` 필드 추가, `healthy`/exit 는 blocking 기준.
29
+ 4. selftest 70→71 · e2e 267→268.
30
+
31
+ ### 검증
32
+ - **selftest 71/71 PASS** · **E2E 268/268 PASS** (회귀 0).
33
+ - 실측: fresh init → `lazy detect` exit **0**(issues=3 advisory, blocking=0, healthy=true) · 거짓완료(done+증거0) 추가 → exit **1**(blocking=3, evidence_missing 차단 유지).
34
+
3
35
  ## 1.9.322 — 2026-06-05 — UR-0044(완료): MCP handler 통합 (_mcpToCliArgs 추출)
4
36
 
5
37
  **🧩 mcpServeCmd 의 인라인 83-case switch(name→cliArgs)를 단일 함수 `_mcpToCliArgs` 로 통합 — ToolRegistry handler 통합 완료.**
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
- [![npm](https://img.shields.io/badge/npm-leerness-blue)](https://www.npmjs.com/package/leerness) [![version](https://img.shields.io/badge/version-1.9.322-green)]() [![tests](https://img.shields.io/badge/e2e-267%2F267-success)]() [![selftest](https://img.shields.io/badge/selftest-70-success)]() [![mcp](https://img.shields.io/badge/MCP--tools-83-brightgreen)]() [![providers](https://img.shields.io/badge/AI_providers-10-brightgreen)]() [![license](https://img.shields.io/badge/license-MIT-lightgrey)]()
6
+ [![npm](https://img.shields.io/badge/npm-leerness-blue)](https://www.npmjs.com/package/leerness) [![version](https://img.shields.io/badge/version-1.9.324-green)]() [![tests](https://img.shields.io/badge/e2e-269%2F269-success)]() [![selftest](https://img.shields.io/badge/selftest-72-success)]() [![mcp](https://img.shields.io/badge/MCP--tools-83-brightgreen)]() [![providers](https://img.shields.io/badge/AI_providers-10-brightgreen)]() [![license](https://img.shields.io/badge/license-MIT-lightgrey)]()
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.322 하네스를 사용합니다. AI 에이전트는 작업 전 `leerness handoff`로 컨텍스트를 적재하고, 작업 후 `leerness check`/`leerness audit`/`leerness session close`를 수행해야 합니다.
474
+ 이 프로젝트는 Leerness v1.9.324 하네스를 사용합니다. 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.322는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **83개 도구**를 노출:
528
+ Leerness v1.9.324는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **83개 도구**를 노출:
529
529
 
530
530
  ```jsonc
531
531
  // 카테고리별
@@ -546,7 +546,7 @@ Leerness v1.9.322는 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.322)** · 매 라운드 GitHub release/태그 생성 · _reports/는 비공개 보존.
549
+ 현재 누적: **70 라운드 (1.9.40 → 1.9.324)** · 매 라운드 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.322: 2026-06-04
587
+ Last synced by Leerness v1.9.324: 2026-06-04
588
588
  <!-- leerness:project-readme:end -->
589
589
 
package/bin/harness.js CHANGED
@@ -9,13 +9,14 @@ const readline = require('readline');
9
9
  // 1.9.274 (UR-0025 1단계): 순수 유틸 함수 모듈 분리 (require-based, 비파괴). selftest 7종이 동작 검증.
10
10
  const { _isSecretKey, compareVer, parseHarnessVersion, _classifyCJK, _riskLabel, _detectSystemLang, _parseSlashFromHelp,
11
11
  PERMISSION_TIERS, _tierRank, _requiredTier, _policyAllows, _resolveNpmTag, _mcpJsonContent, _newRunRecord,
12
- _htmlToText, _extractTitle, _extractLinks } = require('../lib/pure-utils'); // 1.9.318 (UR-0025): 순수 HTML 파싱 유틸 분리
12
+ _htmlToText, _extractTitle, _extractLinks,
13
+ _countDatedBlocks, _extractDecisionBlocks } = require('../lib/pure-utils'); // 1.9.318/324 (UR-0025): 순수 HTML/메모리 파서 분리
13
14
  // 1.9.304 (UR-0025): 순수 분석/검증 함수 모듈 분리.
14
15
  const { _evidenceQuality, _parseEvidenceStats, _shellGuardAnalyze, _claimFileInGit, _epistemicHonestyCheck } = require('../lib/analyzers');
15
16
  // 1.9.295 (UR-0025 4단계): 정적 데이터 카탈로그 모듈 분리 (비파괴, require-based).
16
17
  const { CAPABILITY_SURFACE, POWERFUL_COMMANDS, ADAPTERS, REUSE_CATEGORIES, REUSE_CHECKLIST } = require('../lib/catalogs');
17
18
 
18
- const VERSION = '1.9.322';
19
+ const VERSION = '1.9.324';
19
20
 
20
21
  // 1.9.290 (UR-0037, Codex gpt-5.5 #4 수렴): CLI 전용 부작용은 require 시 실행하지 않는다.
21
22
  // 이전: warning listener 제거 / NODE_OPTIONS 변경 / chcp IIFE 가 top-level 즉시 실행 → require('harness') 시 호스트 프로세스 오염.
@@ -2245,7 +2246,7 @@ function _detectDeliveredRequests(root) {
2245
2246
  if (vMatch && dMatch) {
2246
2247
  const claimedVer = vMatch[1];
2247
2248
  // 현재 버전 이하인지 (자기-기록 시점의 버전이 이미 출시됨)
2248
- const cmp = _compareSemver(claimedVer, currentMajor);
2249
+ const cmp = compareVer(claimedVer, currentMajor); // 1.9.324 (UR-0025): 중복 _compareSemver 제거 → pure-utils compareVer 사용
2249
2250
  if (cmp <= 0) {
2250
2251
  candidates.push({
2251
2252
  id: req.id,
@@ -2261,15 +2262,7 @@ function _detectDeliveredRequests(root) {
2261
2262
  return { total: open.length, candidates, currentVersion: currentMajor };
2262
2263
  }
2263
2264
 
2264
- function _compareSemver(a, b) {
2265
- const pa = String(a).split('.').map(n => parseInt(n, 10) || 0);
2266
- const pb = String(b).split('.').map(n => parseInt(n, 10) || 0);
2267
- for (let i = 0; i < 3; i++) {
2268
- if ((pa[i] || 0) < (pb[i] || 0)) return -1;
2269
- if ((pa[i] || 0) > (pb[i] || 0)) return 1;
2270
- }
2271
- return 0;
2272
- }
2265
+ // 1.9.324 (UR-0025): _compareSemver 제거 — pure-utils compareVer 와 동일 기능(중복) → compareVer 단일화.
2273
2266
 
2274
2267
  // 1.9.226: round-history — git tag v1.9.X 기반 자율 라운드 통계 + 다음 마일스톤
2275
2268
  // git이 없거나 tag가 없으면 graceful fallback (current version + 0 history)
@@ -3122,6 +3115,8 @@ function _selfTestCases() {
3122
3115
  { name: 'count drift 수정: _countDatedBlocks 코드펜스(템플릿) 제외 + 카운트 사이트 단일화 (UR-0053 1.9.320)', run: () => { const f = _countDatedBlocks; const withTpl = '# D\n\n```md\n### 2026-01-01 — Decision 제목\n- Decision:\n```\n\n### 2026-06-04 — 실제\n- Decision: 실제\n'; const c1 = f(withTpl) === 1; const c0 = f('```md\n### 2026-01-01 — x\n```\n') === 0; const c2 = f('### 2026-01-01 — A\n### 2026-02-02 — B\n') === 2; const src = read(__filename); const wired = src.includes('_countDatedBlocks(read(decisionsPath(root)))') && src.includes('_countDatedBlocks(read(lessonsPath(root)))') && src.includes('_countDatedBlocks(dtext)') && !src.includes('read(decisionsPath(root)).' + 'match(/^### '); return typeof f === 'function' && c1 && c0 && c2 && wired; } },
3123
3116
  { name: 'decision/lesson 필드 파싱: 빈 필드가 다음 줄로 안 샘 ([ \\t]* 사용) (UR-0053 1.9.321)', run: () => { const block = '### 2026-06-05 — X\n- Decision: X\n- Reason: r\n- Alternatives: \n- Impact: 보안\n'; const alt = block.match(/- Alternatives:[ \t]*(.+)/); const imp = block.match(/- Impact:[ \t]*(.+)/); const altNoBleed = !alt || !/Impact/.test(alt[1]); const impOk = !!imp && imp[1].trim() === '보안'; const src = read(__filename); const fixedOk = src.includes('- Alternatives:[ \\t]*(.+)') && src.includes('- Lesson:[ \\t]*(.+)') && src.includes('- Impact:[ \\t]*(.+)'); return altNoBleed && impOk && fixedOk; } },
3124
3117
  { name: 'MCP handler 통합: _mcpToCliArgs 단일 함수 + mcpServeCmd 호출 + 인라인 switch 단일화 (UR-0044 1.9.322)', run: () => { const src = read(__filename); const fnDef = /function _mcpToCliArgs\(name, args, targetPath\) \{/.test(src); const called = src.includes('cliArgs = _mcpToCliArgs(name, args, targetPath)'); const switchCount = (src.match(/switch \(name\) \{/g) || []).length; const nullPath = src.includes('if (cliArgs === null) return send('); return fnDef && called && switchCount === 1 && nullPath; } },
3118
+ { name: 'fresh-init gate 통과: lazy detect 부재신호(handoff/test/progress) done-work 없으면 비차단 (UR-0054 ⑥ 1.9.323)', run: () => { const src = read(__filename); const doneWork = src.includes("const _hasDoneWork = rows.some(r => /^(done|completed|verified)$/i.test(r.status))"); const advisory = src.includes('_ADVISORY_KINDS') && src.includes("'handoff_never_generated'") && src.includes("'no_test_run'"); const blocking = src.includes('const blockingIssues = Math.max(0, issues - advisoryCount)') && src.includes('if (blockingIssues > 0) process.exitCode = 1'); return doneWork && advisory && blocking; } },
3119
+ { name: 'lib/pure-utils: 메모리 MD 파서 분리(_countDatedBlocks/_extractDecisionBlocks) + _compareSemver 중복제거 (UR-0025 1.9.324)', run: () => { const m = require('../lib/pure-utils'); const fnOk = typeof m._countDatedBlocks === 'function' && typeof m._extractDecisionBlocks === 'function'; const work = m._countDatedBlocks('```md\n### 2026-01-01 — T\n```\n### 2026-06-05 — R\n') === 1 && m._extractDecisionBlocks('### 2026-06-05 — A\n- Decision: x\n').length === 1; const src = read(__filename); const moved = m._countDatedBlocks === _countDatedBlocks && m._extractDecisionBlocks === _extractDecisionBlocks && !/^function _countDatedBlocks\(/m.test(src) && !/^function _compareSemver\(/m.test(src); return fnOk && work && moved; } },
3125
3120
  { name: 'VERSION 형식 (x.y.z)', run: () => /^\d+\.\d+\.\d+$/.test(VERSION) }
3126
3121
  ];
3127
3122
  }
@@ -7547,23 +7542,31 @@ function lazyDetect(root, opts = {}) {
7547
7542
  issues++; _warn(`blocker without nextAction: ${b.id}`,
7548
7543
  { kind: 'blocker_no_next_action', severity: 'warn', taskId: b.id });
7549
7544
  }
7545
+ // 1.9.323 (UR-0054 ⑥, 설치리뷰): fresh/무작업 프로젝트 gate 통과 — 작업 흔적(done/completed/verified) 없으면
7546
+ // "부재" 신호(progress empty / handoff 미생성·빈 / 테스트 미실행)는 비차단(어드바이저리). active 프로젝트는 기존대로 차단.
7547
+ // 배경: leerness init 직후 leerness gate 가 빈 트래커·미생성 handoff 때문에 즉시 실패하던 UX 결함.
7548
+ const _hasDoneWork = rows.some(r => /^(done|completed|verified)$/i.test(r.status));
7549
+ const _ADVISORY_KINDS = new Set(['progress_empty', 'handoff_never_generated', 'handoff_empty', 'no_test_run']);
7550
+ const advisoryCount = _hasDoneWork ? 0 : findings.filter(f => _ADVISORY_KINDS.has(f.kind)).length;
7551
+ const blockingIssues = Math.max(0, issues - advisoryCount);
7550
7552
  // 1.9.101: JSON 모드 → 구조화 출력만 (process.exitCode는 일관 유지)
7551
7553
  if (jsonMode) {
7552
7554
  const payload = {
7553
7555
  version: VERSION,
7554
7556
  root,
7555
7557
  issues,
7556
- healthy: issues === 0,
7558
+ blockingIssues,
7559
+ healthy: blockingIssues === 0,
7557
7560
  todoCount,
7558
7561
  newTodoCount: newTodos.length,
7559
7562
  findings,
7560
7563
  };
7561
7564
  process.stdout.write(JSON.stringify(payload, null, 2) + '\n');
7562
- if (issues > 0) process.exitCode = 1;
7565
+ if (blockingIssues > 0) process.exitCode = 1;
7563
7566
  return;
7564
7567
  }
7565
- if (issues === 0) ok('lazy detect passed (no obvious lazy work signals)');
7566
- else { fail(`lazy detect found ${issues} issues`); process.exitCode = 1; }
7568
+ if (blockingIssues === 0) ok(advisoryCount > 0 ? `lazy detect passed (${advisoryCount} advisory, 0 blocking — 작업 흔적 없는 fresh 프로젝트)` : 'lazy detect passed (no obvious lazy work signals)');
7569
+ else { fail(`lazy detect found ${blockingIssues} blocking issues`); process.exitCode = 1; }
7567
7570
  }
7568
7571
 
7569
7572
  function preCheck(root) {
@@ -12819,20 +12822,7 @@ function readSessionCounter(root) {
12819
12822
  }
12820
12823
  function writeSessionCounter(root, c) { writeUtf8(sessionCounterPath(root), JSON.stringify(c, null, 2) + '\n'); }
12821
12824
 
12822
- // 1.9.14 A/D: 결정 블록 추출 코드 블록 안의 ### + Template 제외
12823
- // 1.9.320 (UR-0053, 설치리뷰): 날짜 블록(### YYYY-MM-DD) 카운트 단일 진실소스 — 코드펜스(```md 템플릿 예시) 제거 후 카운트.
12824
- // 배경: decisions/lessons 카운터 6곳이 raw regex 로 코드펜스 안 Template 예시까지 세어 count drift(decisions=2 실제1) 발생.
12825
- function _countDatedBlocks(text) {
12826
- const cleaned = String(text || '').replace(/^```[^\n]*\n[\s\S]*?\n```\s*$/gm, ''); // 코드펜스(템플릿) 제거
12827
- return (cleaned.match(/^### \d{4}-\d{2}-\d{2}/gm) || []).length;
12828
- }
12829
- function _extractDecisionBlocks(text) {
12830
- // 줄 시작의 ```부터 줄 시작의 ```까지를 코드블록으로 인식 (인라인 백틱 무시)
12831
- const cleaned = String(text || '').replace(/^```[^\n]*\n[\s\S]*?\n```\s*$/gm, '');
12832
- return cleaned.split(/\n(?=### )/).filter(b =>
12833
- b.startsWith('### ') && !/^### (Template|템플릿)\b/.test(b.trim())
12834
- );
12835
- }
12825
+ // 1.9.324 (UR-0025): _countDatedBlocks / _extractDecisionBlocks lib/pure-utils.js 이동 (순수 메모리 MD 파서, require 사용).
12836
12826
 
12837
12827
  function _retroAggregate(root) {
12838
12828
  root = absRoot(root);
package/lib/pure-utils.js CHANGED
@@ -196,11 +196,27 @@ function _extractLinks(html, baseUrl, maxLinks) {
196
196
  return Array.from(found.values());
197
197
  }
198
198
 
199
+ // 1.9.324 (UR-0025): 순수 메모리 MD 파서 — 코드펜스(```md 템플릿 예시) 제거 후 날짜 블록(### YYYY-MM-DD) 카운트/추출.
200
+ // count drift(템플릿 오집계) 방지의 단일 진실소스. decisions/lessons 카운터가 공유.
201
+ function _countDatedBlocks(text) {
202
+ const cleaned = String(text || '').replace(/^```[^\n]*\n[\s\S]*?\n```\s*$/gm, ''); // 코드펜스(템플릿) 제거
203
+ return (cleaned.match(/^### \d{4}-\d{2}-\d{2}/gm) || []).length;
204
+ }
205
+ function _extractDecisionBlocks(text) {
206
+ // 줄 시작의 ```부터 줄 시작의 ```까지를 코드블록으로 인식 (인라인 백틱 무시)
207
+ const cleaned = String(text || '').replace(/^```[^\n]*\n[\s\S]*?\n```\s*$/gm, '');
208
+ return cleaned.split(/\n(?=### )/).filter(b =>
209
+ b.startsWith('### ') && !/^### (Template|템플릿)\b/.test(b.trim())
210
+ );
211
+ }
212
+
199
213
  module.exports = {
200
214
  _isSecretKey, compareVer, parseHarnessVersion,
201
215
  _classifyCJK, _riskLabel, _detectSystemLang, _parseSlashFromHelp,
202
216
  // 1.9.283 (UR-0025 2단계)
203
217
  PERMISSION_TIERS, _tierRank, _requiredTier, _policyAllows, _resolveNpmTag, _mcpJsonContent, _newRunRecord,
204
218
  // 1.9.318 (UR-0025): 순수 HTML 파싱 유틸
205
- _htmlToText, _extractTitle, _extractLinks
219
+ _htmlToText, _extractTitle, _extractLinks,
220
+ // 1.9.324 (UR-0025): 순수 메모리 MD 파서
221
+ _countDatedBlocks, _extractDecisionBlocks
206
222
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leerness",
3
- "version": "1.9.322",
3
+ "version": "1.9.324",
4
4
  "description": "Leerness: 비파괴 마이그레이션, 자동 버전 감지·업데이트, 계획/진행/핸드오프 자동화, 게으름·시크릿·인코딩 자동 가드, Claude Code 슬래시 통합을 갖춘 한국어 우선 AI 개발 하네스.",
5
5
  "keywords": [
6
6
  "leerness",
package/scripts/e2e.js CHANGED
@@ -3791,7 +3791,7 @@ total++;
3791
3791
  && m._extractTitle('<title>T &amp; U</title>') === 'T & U'
3792
3792
  && m._extractLinks('<a href="/x">x</a><a href="https://o.com/y">y</a>', 'https://h.com/').length === 1; // same-domain only
3793
3793
  const harnessSrc = fs.readFileSync(path.resolve(__dirname, '..', 'bin', 'harness.js'), 'utf8');
3794
- const movedOut = !/function _htmlToText\(html\) \{/.test(harnessSrc) && /_htmlToText, _extractTitle, _extractLinks \} = require\('\.\.\/lib\/pure-utils'\)/.test(harnessSrc);
3794
+ const movedOut = !/function _htmlToText\(html\) \{/.test(harnessSrc) && harnessSrc.includes('_htmlToText, _extractTitle, _extractLinks') && /require\('\.\.\/lib\/pure-utils'\)/.test(harnessSrc); // 1.9.324: import 순서 비의존(이후 import 추가 허용)
3795
3795
  const r = cp.spawnSync(process.execPath, [CLI, 'api-skill'], { encoding: 'utf8', timeout: 15000 }); // 소비 명령 로드
3796
3796
  const cmdOk = /api-skill/.test(r.stdout || '');
3797
3797
  ok = fnOk && work && movedOut && cmdOk;
@@ -3876,5 +3876,48 @@ total++;
3876
3876
  if (!ok) failed++;
3877
3877
  }
3878
3878
 
3879
+ // 1.9.323 회귀 (UR-0054 ⑥): fresh init → gate(lazy detect) 통과(부재신호 비차단) + active 거짓완료는 차단 유지
3880
+ total++;
3881
+ {
3882
+ let ok = false;
3883
+ try {
3884
+ const fg = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-freshgate-'));
3885
+ cp.spawnSync(process.execPath, [CLI, 'init', fg, '--yes', '--language', 'ko', '--skills', 'recommended'], { encoding: 'utf8', timeout: 30000 });
3886
+ const freshExit = cp.spawnSync(process.execPath, [CLI, 'lazy', 'detect', fg], { encoding: 'utf8', timeout: 20000 }).status; // fresh → 통과(0)
3887
+ // 거짓완료(done + 증거0) 추가 → 다시 lazy detect → 차단(1)
3888
+ cp.spawnSync(process.execPath, [CLI, 'task', 'add', '거짓완료', '--status', 'done', '--evidence', '', '--path', fg, '--no-review', '--force'], { encoding: 'utf8', timeout: 20000 });
3889
+ const activeExit = cp.spawnSync(process.execPath, [CLI, 'lazy', 'detect', fg], { encoding: 'utf8', timeout: 20000 }).status; // 거짓완료 → 차단(1)
3890
+ ok = freshExit === 0 && activeExit === 1;
3891
+ fs.rmSync(fg, { recursive: true, force: true });
3892
+ } catch {}
3893
+ console.log(ok ? '✓ B(1.9.323) fresh-init gate: lazy detect 부재신호 비차단(통과) + 거짓완료 차단 유지 (UR-0054 ⑥)' : '✗ fresh-init gate 실패');
3894
+ if (!ok) failed++;
3895
+ }
3896
+
3897
+ // 1.9.324 회귀 (UR-0025 모듈화): 메모리 MD 파서 2종 lib/pure-utils 분리 + harness 인라인 제거 + _compareSemver 중복제거 + 소비명령
3898
+ total++;
3899
+ {
3900
+ let ok = false;
3901
+ try {
3902
+ const m = require(path.resolve(__dirname, '..', 'lib', 'pure-utils.js'));
3903
+ const fnOk = typeof m._countDatedBlocks === 'function' && typeof m._extractDecisionBlocks === 'function';
3904
+ const work = m._countDatedBlocks('```md\n### 2026-01-01 — T\n```\n### 2026-06-05 — R\n') === 1
3905
+ && m._extractDecisionBlocks('### 2026-06-05 — A\n- Decision: x\n').length === 1;
3906
+ const harnessSrc = fs.readFileSync(path.resolve(__dirname, '..', 'bin', 'harness.js'), 'utf8');
3907
+ const movedOut = !/function _countDatedBlocks\(/.test(harnessSrc) && !/function _compareSemver\(/.test(harnessSrc)
3908
+ && /_countDatedBlocks, _extractDecisionBlocks \} = require\('\.\.\/lib\/pure-utils'\)/.test(harnessSrc);
3909
+ // 소비 명령 회귀: context 의 decisions count (_countDatedBlocks 사용)
3910
+ const cd = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-memparse-'));
3911
+ cp.spawnSync(process.execPath, [CLI, 'init', cd, '--yes', '--language', 'ko', '--skills', 'recommended'], { encoding: 'utf8', timeout: 30000 });
3912
+ cp.spawnSync(process.execPath, [CLI, 'decision', 'add', 'X', '--path', cd, '--reason', 'r'], { encoding: 'utf8', timeout: 20000 });
3913
+ const r = cp.spawnSync(process.execPath, [CLI, 'context', '--path', cd, '--json'], { encoding: 'utf8', timeout: 20000 });
3914
+ let decOk = false; try { decOk = JSON.parse(r.stdout).memory.decisions === 1; } catch {}
3915
+ ok = fnOk && work && movedOut && decOk;
3916
+ fs.rmSync(cd, { recursive: true, force: true });
3917
+ } catch {}
3918
+ console.log(ok ? '✓ B(1.9.324) lib/pure-utils 메모리 파서 분리: 모듈 단일출처 + 인라인/중복 제거 + context count (UR-0025)' : '✗ 메모리 파서 분리 실패');
3919
+ if (!ok) failed++;
3920
+ }
3921
+
3879
3922
  console.log(`\nE2E result: ${total - failed}/${total} passed · ${((Date.now() - _e2eStart) / 1000).toFixed(0)}s`);
3880
3923
  if (failed > 0) process.exit(1);