Commit Graph
3 Commits
Author SHA1 Message Date
DongHyeonka d31c7d6b18 fix(recipes): 세션 파일 레시피가 매뉴얼과 같은 capability 타입 위치를 가리킨다
문제: 세션 레시피 주석이 "`FeaturePlatformCapabilities`를
`files: SessionBrowserFiles`로 보강한다"고 적는다. 매뉴얼
(`docs/manual/03-outside-feature-folder.md`)은 그 타입을
`src/features/product-capabilities.ts`의
`ProductFeaturePlatformCapabilities`에 적으라고 하고, `declare module`
보강은 `check:types:node`가 키를 보지 못한다고 막는다. 주석대로 하면 앱
typecheck는 통과하고 node typecheck에서 키를 잃는다. 또 레시피 테스트는
`capabilities: {}`로 조립하고 `files.current()`를 레시피 객체에서 직접
불러서, capability가 기능 쪽으로 넘어가는 절반이 깨져도 통과한다.

고른 방법:
- 주석이 `ProductFeaturePlatformCapabilities`에 적는 예와 매뉴얼 경로를
  보이고, `declare module` 보강은 쓰지 말라고 적는다.
- 레시피 테스트가 `capabilities: { files }`를 돌려주고, 템플릿이 설치된
  기능의 loader에 넘기는 capability 객체(`createInstalledFeatureLoaders`의
  첫 인자)를 기록한다. 테스트의 모든 파일 동작(선택, 읽기, download,
  계정 전환 뒤 새 runtime)을 그 객체의 `files.current()`로 돈다. 같은
  mock 방식은 `tests/recipes/session-owners-runtime.test.ts`가 이미 쓴다.

버린 대안: `files`를 `needs`에 적은 가짜 기능을 생성 index에 끼워 넣기.
`ProductFeaturePlatformCapabilities`가 비어 있는 템플릿에서는 타입을
우회해야 하고, `needs`로 고르는 부분은 1103/09-08 테스트가 이미 잡는다.

위험·한계: 검사는 loader가 받는 capability 객체까지다. 기능 factory가
`needs`로 골라 받는 마지막 단계는 기존 테스트에 맡긴다. 동작 코드는
바뀌지 않는다(주석과 테스트만).

검증: desktop batch에서 확인
- node scripts/run-vitest.ts run tests/recipes/browser-file-session-capability.test.ts
- 변이: 테스트 mock의 `capabilities`에서 `files`를 빼거나,
  `src/bootstrap/runtime-adapters.ts`의 `...product.capabilities`를 지우면
  "Features did not receive the files capability"로 실패해야 한다.

Refs: 1105/02-03
2026-11-05 22:16:46 +09:00
DongHyeonka b9524cfdd5 test(storage): scope participant 조립 테스트가 제품 설정 기본값을 같이 받는다
문제
fix/r1103-storage가 더한 browser-file-session-capability·
runtime-adapters-product-scope-participants 테스트는 RuntimeConfig를
글자 그대로 적는다. fix/r1103-app(09-02)의 제품 확장 타입 검사
테스트가 이 두 파일에서 TS2322로 실패한다(9b9d62a와 같은 원인).

고른 방법
- 두 테스트도 testRuntimeConfig로 설정을 만든다.

위험·한계
- 동작 변경은 없다.

검증
- tests/unit/product-extension-typecheck.test.ts, 두 테스트, test:recipes,
  lint 통과.

Refs: docs/reviews/2026-11-03-maturity-review/02-adapters-browser-files-cache.md 02-01
2026-11-04 21:50:30 +09:00
DongHyeonka f485e51e21 feat(bootstrap): 제품이 세션과 함께 닫을 것을 scopeParticipants로 넘긴다
문제: browser-files runtime은 세션을 모르고, 닫는 수단은
runtime.dispose() 하나다. 설계 문서는 로그아웃·계정 전환에 "server-state
scope reset participant로 dispose()를 등록하라"며 템플릿 소유 파일
runtime-adapters.ts를 가리키는데, 매뉴얼은 제품이 그 파일을 고치지
않는다고 한다(09-02). 제품 확장 지점 composeProduct는 부팅 때 한 번
불리고, context에 participant 등록도 lifecycle 구독도 없다. 그래서
연결하지 않으면 이전 사용자가 고른 File, preview blob URL, 진행 중
download가 다음 세션까지 남는다(공유 기기에서 이전 사용자 파일이
메모리와 다운로드 폴더에 남을 수 있다).

고른 방법(리뷰 5.3절 (다) + 레시피 예제):
- ProductComposition에 선택 칸 scopeParticipants(ProductScopeParticipant:
  label, close)를 둔다. 템플릿은 scope reset의 §10.6 10단계(offline
  lease 해제) 자리에 "product" participant 하나를 두고, composeProduct가
  돌려준 것을 순서대로 부른다. 하나가 실패해도 나머지를 부르고, 실패가
  있으면 template participant와 같이 READY로 가지 않는다(FAILED).
  composeProduct는 scope가 생긴 뒤 불리므로(context가 fence를 쓴다) 이
  자리를 미리 만들고 나중에 채운다.
- recipes/frontend-capabilities/browser-file-session-capability.ts:
  기능에는 runtime 대신 current() getter를 주고, participant가 dispose한
  뒤 다음 호출에서 새 runtime을 만든다. indexeddb 레시피와 같은 자리다.
- 설계 문서와 매뉴얼 03 C절이 이 방법을 가리킨다. 제거 드릴이 새
  레시피 파일도 같이 지운다.
버린 대안: (가) 문서만 고침 — feature presentation은 adapter를 만들 수
없어 제품마다 factory를 다시 설계한다. (나) context에 lifecycle 구독
위임 — FENCED → participant → READY 순서와 "실패는 READY를 막는다"를
제품이 직접 지켜야 한다. (라) runtime이 세대 AbortSignal을 받음 —
adapter가 세대를 알게 되고 다른 opt-in runtime도 따로 받아야 한다.

위험·한계:
- 제품 계약 표면이 하나 는다(선택 칸이라 기존 제품 파일은 그대로
  컴파일된다, [계약]).
- 기능은 current()를 작업마다 불러야 한다. 이전 세대에서 받은 runtime을
  들고 있으면 UNAVAILABLE을 받는다. FENCED 동안 current()를 부르면 다음
  세대 runtime이 미리 만들어진다(빈 runtime이라 이전 사용자 데이터는
  없다).
- app dispose(infrastructure.dispose)는 제품 participant를 부르지 않는다.
- 실제 브라우저 2탭 로그아웃 E2E는 없다(조립된 화면이 없다).
- scripts/test-browser-file-storage-runtime-removal.ts는 02-06 담당 작업도
  고칠 수 있는 파일이다. runtimePaths에 한 줄만 더했다.

검증:
- RED: tests/recipes/browser-file-session-capability.test.ts가 계정 전환
  뒤에도 이전 runtime의 readRange가 ok로 실패.
- GREEN: 같은 테스트에서 계정 전환 뒤 ① 이전 runtime readRange
  UNAVAILABLE ② 진행 중 bounded download ABORTED, handoff 0회 ③ 새 세대
  runtime의 파일 선택 SELECTED. tests/unit/runtime-adapters-product-scope-
  participants.test.ts 2건(순서, 실패 시 FAILED와 나머지 실행).
- 변이 4개(등록 누락, 실패 삼킴, 첫 실패에서 멈춤, 레시피 dispose 누락)
  모두 새 테스트가 잡았다.
- runtime-adapters 관련 unit 3파일 + tests/recipes 47건 통과.
  check:types, 바꾼 파일 eslint, check:architecture, verify:documentation
  통과.

Refs: docs/reviews/2026-11-03-maturity-review/02-adapters-browser-files-cache.md 02-01
2026-11-04 20:54:20 +09:00